

NewT.js - pure JS templating engine - gregory80
http://newtjs.org/

======
anko
this reminds me of superflyDOM:
[http://docs.jquery.com/Plugins/SuperFlyDOM/createAppend#elem...](http://docs.jquery.com/Plugins/SuperFlyDOM/createAppend#elementattributeschildren)

I saw it used in a project once and it was a disaster.  The problem being, by
using javascript to represent html you are making your templates harder to
write and harder to maintain. 

This solution certainly has some cool features, but I strongly disagree with
comparisons to haml.  Where haml strips away a bunch of html syntactical
weight, newt.js piles it on. 

Sorry if i'm being too strong, but I just wanted to share my
thoughts/experiences/criticism.  It is clear the author has put a lot of work
into this, including tests. 

I like <http://www.handlebarsjs.com/> for my javascript templating because I
can literally cut and paste in some html into a template, add some
logic(if/then blocks) and I'm done. 

~~~
insin
I started coming to a similar conclusion about pure-JavaScript templating in
terms of ease of writing and maintenance after getting most of the way into
implementing a templating plugin for my DOMBuilder library, based on this
speculative API extracted from a sample Django template:
<https://gist.github.com/958838>

Once you start piling on the mixed, nested content and a mix of elements with
and without attributes, it takes some diligence to ensure you've put all your
commas and parentheses in the right place first time, and the resulting code
isn't all that pleasing on the eye when you compare it to the usual HTML with
placeholders for logic/dynamic content. 

I still find this style of templating useful for smaller chunks of content
like this sort of thing, though:

    
    
      function dataTable(headers, objects, properties) {
        return TABLE({cellSpacing: 1, 'class': 'data sortable'}
        , THEAD(TR(TH.map(headers)))
        , TBODY(TR.map(objects, function(obj, attrs, loop) {
            attrs['class'] = (loop.index % 2 == 0 ? ' odd', 'even')
            return TD.map(properties, function(prop) {
              return obj[prop]
            })
          }))
        )
      }

------
taitems
Using "clss" to avoid a conflict seems really clunky.  className?  @class?