Hacker News new | ask | show | jobs
by gcao 4775 days ago
Interesting project. I feel it is similar to https://github.com/gcao/T.js - my little Javascript template engine. However IMHO, json2html is too verbose for large document, and T.js is concise and provides some nice features(e.g. layout, attributes as hash etc).

Below is a T.js template written in Coffeescript. <code> tournamentResultTemplate = (data) -> return unless data.result

  [ "div.detail"
    [ "table"
      [ "tr"
        ["td", "Result"]
        ["td", data.result]
      ]
      if data.defeated
        [ "tr"
          ["td", "Defeated"]
          ["td", data.defeated]
        ]
      if data.lost_to
        [ "tr"
          ["td", "Lost to"]
          ["td", data.lost_to]
        ]
    ]
  ]
</code>