Hacker News new | ask | show | jobs
by bretthopper 5238 days ago
This is an interesting approach. One downside is that it's much less readable than the Handlebars template. Using Coffeescript for the "templating" functions would actually clean it up a lot.
1 comments

Would you mind posting a Coffeescript snippet to demonstrate that?

  items = [ 1, 2, 3, 4 ]
  el 'div#message', [
    el 'a.biglink', href: 'http://www.google.com', [ 'A link to Google' ]
    el 'ul',
      el 'li.item', [ "#{item}. Item" ] for item in items
    'There are lots of items'.localise() + '. ' if items.length > 1
    'This is just plain text. <script>I have no effect</script>' ]