top | item 2348748

Tempo: a tiny JSON rendering engine

107 points| rafaelc | 15 years ago |twigkit.github.com | reply

24 comments

order
[+] franze|15 years ago|reply
is the unobtrusive javascript paradigm dying or already dead?
[+] ehsanul|15 years ago|reply
From the link: Degrades gracefully if JavaScript is not enabled

Graceful degradation is less common for JavaScript now than it used to be though. So if you want a smooth web experience, these days you just can't go without JavaScript. I personally don't think that's a horrible thing, but I guess most people who've disabled JavaScript (or use Lynx or something) would disagree.

[+] tomjen3|15 years ago|reply
Javascript is pretty much necessary to browse the web these days, unless you stick to things like wikipedia, and only write text.
[+] robryan|15 years ago|reply
I generally pass the templates needed for a page into a Javascript variable from the back end. Looks nice for template nesting though, as opposed to storing a nested template in a separate Javascript variable.
[+] Ataraxy|15 years ago|reply
As someone that isn't really a developer but understands enough to break things or cobble them together, this seems quite accessible to me.

For example, I could conceivably see taking an existing web services API and spitting JSON results into a themeforest template.

I'm sure there's a million ways of doing it, but this at a glance seems like a quick way of making that happen.

[+] etherealG|15 years ago|reply
sorry to be a hater, but while I find the idea of mixing js and html not great, the alternative being offered up here is to introduce a new language and mix that in with html instead of js. isn't that counterintuitive? wouldn't it be better to just use actual js in your templates instead of this arbitrary {{}}-based stuff?
[+] biot|15 years ago|reply
It's a very familiar style of markup that I find immediately intuitive. The benefit being that it separates the markup from the code populating it.
[+] zdw|15 years ago|reply
Looks interesting, especially to those coming from Smarty as it appears quite similar in terms of templating.

To compare the two, the upside is you get to feed the site JSON, which is easier to generate. The downside is the extra content load time of the script vs doing the template integration server side and caching the result.

[+] d0m|15 years ago|reply
Interesting. At first sight, I couldn't really understand the difference with the existing icanhazjs(.com) library? Can you elaborate on this?
[+] aitorciki|15 years ago|reply
How well does the {{}} syntax coexist with server-side template languages like Django's one which uses the exact same marker for placeholders?
[+] d0m|15 years ago|reply
You can use tags in your django templates do avoid that issue. For instance, I am using icanhaz which use mustache's templates ({{}}) and I inspired myself of a snippet called Verbatim. So, basically, in your template you do:

  <body>
  {% js_template test %}
  Here you can freely use {{}} because the surrounding tags make django ignore them.
  {% endjs_template %}