twigkit / tempo

Tempo is an easy, intuitive JavaScript rendering engine that enables you to craft data templates in pure HTML.
http://tempojs.com/
Apache License 2.0
709 stars 72 forks source link

Unexpected token !== tempo.js:385 #91

Open BMeridian opened 10 years ago

BMeridian commented 10 years ago

Using the line below with nunjucks...I get an error

Tempo.prepare('template', {'var_braces' : '[[]]', 'tag_braces' : '[\?\?]'}).render(data);

Uncaught SyntaxError: Unexpected token !== tempo.js:385 Templates.templateFor tempo.js:385 Renderer.renderItem tempo.js:566 Renderer._createFragment tempo.js:651 Renderer.append tempo.js:686 Renderer.render tempo.js:675 (anonymous function) index2:50 l jquery-2.0.3.js:2913 c.fireWith jquery-2.0.3.js:3025 x.extend.ready jquery-2.0.3.js:398 S jquery-2.0.3.js:93

mrolafsson commented 10 years ago

I think you need to double escape these?

Tempo.prepare('marx-brothers', {'var_braces' : '\\[\\[\\]\\]', 'tag_braces' : '\\[\\?\\?\\]'});
BMeridian commented 10 years ago

Yeah, They are. I use directly from docs. changed marx-bro --> template.. The extra "\" disappeared on copy/paste. I really want this to work.
Has this been tested with Flask -- use jinga2 templating engine..

BMeridian commented 10 years ago

Ok, solved something. Since I am trying to use two templating engine. I am having problem. From the server I am getting three data sets. jinga2 parses some. I want tempo to parse the rest.

Lets say the three sets are items, data01, data11. could be more. jinga handles items. I want tempo to handle others. When I write {{data01}} {{data11}} in the index.html, get object Object, a bunch of times. So the data comes over. How can I get these two datasets, in form to use [[ ]] method to apply .render(data01) .render(data11) and start using the templates.

mrolafsson commented 10 years ago

I would expect this to work? Are you saying that the square bracket override is not being picked up?