Is there an alternative to HTML?

HtmlCross Compiling

Html Problem Overview


Is there a language I can use to write my website's HTML, which:

  • converts to HTML without having to write the HTML directly
  • has all the power of HTML
  • is less verbose than HTML and XML

For example, it should be to HTML what CoffeeScript is to JS.

Also, what is your experience with whatever you suggest?

Also have a look at Comparison of web template engines and Scala Tags

Html Solutions


Solution 1 - Html

A good choice is Haml. In Haml, you write highly structured markup that resembles a stripped-down form of HTML, and where common things have easy shortcuts. For example, adding an element, div, id, or class is done just by changing one character.

It even lets you pass variables in and operate on them in the language of your choice by deferring to a scripting language, so it's actually more powerful than HTML since the implicit scripting makes it Turing-complete.

Here's an example:

  %body
    #header
      %h1 Bob Loblaw's Law Blog
      %h2 by Bob Loblaw
    #content
      - @entries.each do |entry|
        .entry
          %h3.title= entry.title
          %p.date= entry.posted
    #footer
      %p
        All content copyright © Bob Loblaw.

This becomes something like:

<div id='header'>
  <h1>Bob Loblaw's Law Blog</h1>
  <h2>by Bob Loblaw</h2>
</div>
<div id='content'>
  <div class='entry'>
    <h3 class='title'>You don't need double-talk; you need Bob Loblaw</h3>
    <p class='date'>Tuesday, October 31, 2006</p>
  </div>
  <div class='entry'>
    <h3 class='title'>Why should you go to jail for a crime someone else noticed?</h3>
    <p class='date'>Friday, August 11, 2006</p>
  </div>
</div>
<div id='footer'>
  <p>
    All content copyright © Bob Loblaw.
  </p>
</div>

Solution 2 - Html

A friend and I just started Layx: a new layout language based on Cassowary, the constraint solving toolkit that Apple is using for their user interfaces. It's only for web now, but it will be multiplatform -mobile natively- someday.

It is designed to be extremely simple and easy (like python), and as asked, it compiles internally to HTML, dynamically, as the interface has to be updated if layers have to be moved or resized.

It's a really new project -alpha version-, so try it knowing that.

Project website: http://www.layx.org/

Online demo: http://www.layx.org/demo/

Open Source repository: http://github.com/layxlang/layx

I hope it helps and feedback is always welcome!

Regards

EDIT (8 Jan, 2015): Open source link added

EDIT (15 Jan, 2015): Demo link added

Solution 3 - Html

You're essentially asking for a lightweight markup language that can be converted to HTML, popular/well-known examples of which include BBCode, Markdown, and MediaWiki markup.

Solution 4 - Html

I know the question is old but I got to it searching for answers, and I thought I would update the replies with my own.

As already pointed, the question asks primarily for template engines (not so much languages) as the point is generating HTML.

If the objective is to be consistent with CoffeeScript, then CoffeeKup is the way to go. Personally, among the ones that I have seen, in the search for terseness, Pug is the one that looks best to me, it is heavily influenced by Haml (accepted and top answer), and improves it (IMHO) in several aspects: more terse, more elegant and clear (subjective, fair enough) and does not require Ruby, as it is JavaScript based.

Solution 5 - Html

You can define your website as XML using your own custom format, and then convert to HTML using XSLT. Done it in the past :)

Solution 6 - Html

You may be looking for something like this:

http://code.google.com/p/zen-coding/

Though I seem to recall someone already answered this question a while ago.

Solution 7 - Html

You can try Processing.js. You'll still need a HTML shell to host the canvas, but you can actually code your site with Processing/Java.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlexView Question on Stackoverflow
Solution 1 - HtmlJohn FeminellaView Answer on Stackoverflow
Solution 2 - HtmlaxelbrzView Answer on Stackoverflow
Solution 3 - HtmljwodderView Answer on Stackoverflow
Solution 4 - HtmlTrylksView Answer on Stackoverflow
Solution 5 - HtmlChris DennettView Answer on Stackoverflow
Solution 6 - HtmlarkigosView Answer on Stackoverflow
Solution 7 - HtmlRoger SodréView Answer on Stackoverflow