News for hackers. Stuff that matters.
Re:Tempo: a tiny JSON rendering engine by y0ghur7_xxx on Monday March 21, 2011 @03:56AM (#2348853)
Here[1] is a list of other JS templating engines. The page compares them for speed.

You could add yours.

[1]http://jsperf.com/dom-vs-innerhtml-based-templating/112

Re:Tempo: a tiny JSON rendering engine by franze on Monday March 21, 2011 @03:44AM (#2348842)
is the unobtrusive javascript paradigm dying or already dead?
Re:Tempo: a tiny JSON rendering engine by ehsanul on Monday March 21, 2011 @05:03AM (#2348962)
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.

Re:Tempo: a tiny JSON rendering engine by wladimir on Monday March 21, 2011 @08:11AM (#2349344)
The only thing I was still using Lynx for is for downloading graphics drivers on Linux. Alas, since NVIDIA did their last site update, that doesn't seem to work anymore :(

I think that if your site has a clear-cut function, you should at least try to provide that functionality even for bare-html browsers. Doesn't matter if it looks ugly, the focus is this case is on functionality not looks.

Re:Tempo: a tiny JSON rendering engine by etherealG on Monday March 21, 2011 @05:23AM (#2348999)
I think that's just a result of lazy programmers. Most of the sites I put together work with or without js. It's not that hard to do with a good templating engine that splits up each "ajax" part of html into a piece that can be rendered with a refetch of the entire page, or a refetch of just that part.
Re:Tempo: a tiny JSON rendering engine by franze on Monday March 21, 2011 @06:39AM (#2349122)
i.e.: http://twigkit.github.com/tempo/examples/twitter with no-script turned on http://yfrog.com/h2g6vcqj well, i'm not quite sure how "Degrades gracefully" is defined, but i would not call the no js-version "gracefully"
Re:Tempo: a tiny JSON rendering engine by tomjen3 on Monday March 21, 2011 @05:20AM (#2348995)
Javascript is pretty much necessary to browse the web these days, unless you stick to things like wikipedia, and only write text.
Re:Tempo: a tiny JSON rendering engine by _delirium on Monday March 21, 2011 @06:22AM (#2349098)
I haven't had big troubles for browsing the web, though interacting with it (e.g. posting stuff in comment areas) is more problematic. Looking at the sites I regularly visit, all can be browsed fine without js: Wikipedia, HN, Reddit, Twitter, any Wordpress blog, Slashdot, Google News and just about everything it links to, university professor/project websites, etc.

In fact, I can't think of a site I regularly visit that doesn't work without js, except for things clearly in the category of "web apps", like canvaspaint.org, where the idea of "browsing" them doesn't even necessarily make sense. Even gmail works without js!

Re:Tempo: a tiny JSON rendering engine by qntm on Tuesday March 22, 2011 @08:34AM (#2354022)
I feel necessary to point out that the sites you regularly visit seem to fall in two broad categories. Wikipedia, Slashdot and so on are enormous sites with vast user bases and advanced JS, where any JavaScript functionality has to be backed up with plain old HTML or the site becomes unusable for a significant number of people. University websites are in my experience much smaller sites with a very strong emphasis on factual content and almost no JavaScript at all in the first place.

The problematic sites are going to be the middle ground - large-ish sites with reasonably competent web developers who have higher priorities than supporting the 1% of users who have JavaScript disabled.

Re:Tempo: a tiny JSON rendering engine by MatthewPhillips on Monday March 21, 2011 @07:47AM (#2349275)
Just out of curiosity, why do you browse without javascript?
Re:Tempo: a tiny JSON rendering engine by _delirium on Monday March 21, 2011 @08:51AM (#2349433)
I don't regularly anymore, but until a few months ago my main portable coffee-shop machine was an old 12" Powerbook G4, which was a lot snappier with js turned off, especially on a few sites whose dynamic versions were slow as molasses, like Slashdot. Probably close to a worst case for js, because not only was the machine slow and low on RAM, but browsers use old fall-back js engines on PPC.

I also use 'links' from a terminal on occasion. It's gotten increasingly hard to use, but mostly due to layout issues rather than js, afaict.

Re:Tempo: a tiny JSON rendering engine by thefreshteapot on Monday March 21, 2011 @03:22AM (#2348821)
As a user of the "prototype.js" library this is a little similar to the default template syntax, yet with one extra character.

Thomas Fuchs has a very similar version: http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-...

And finally, I ported the template functionality from the "prototype.js" to php. https://github.com/freshteapot/php-template

Prototypejs - api of "Template" http://api.prototypejs.org/language/Template/

Re:Tempo: a tiny JSON rendering engine by robryan on Monday March 21, 2011 @02:56AM (#2348768)
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.
Re:Tempo: a tiny JSON rendering engine by Ataraxy on Monday March 21, 2011 @05:31AM (#2349008)
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.

Re:Tempo: a tiny JSON rendering engine by etherealG on Monday March 21, 2011 @05:22AM (#2348997)
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?
Re:Tempo: a tiny JSON rendering engine by biot on Monday March 21, 2011 @06:06AM (#2349066)
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.
Re:Tempo: a tiny JSON rendering engine by weego on Monday March 21, 2011 @07:05AM (#2349181)
{{tag}} is not "valid" markup (it will pass a validator but has negative semantic value), which is even worse than mixing a little well crafted logic into your display code.
Re:Tempo: a tiny JSON rendering engine by biot on Monday March 21, 2011 @07:31AM (#2349239)
Using {{tag}} notation seems to work well enough on Wikipedia -- could you elaborate on the difference between Tempo's use and Wikipedia's?
Re:Tempo: a tiny JSON rendering engine by etherealG on Monday March 21, 2011 @11:34AM (#2350148)
I don't seem much difference, but I also prefer when making websites to keep down the number of languages I have to know. Already html + css + js + a server side language is enough, introducing another seems excessive when your templating language could just be js or perhaps the same server side language you already use.

we do the same for our server side templating when making sites, using php for controller & model code, but also arbitrary php as the template language in the view too. it seems to work well, and avoids the need to learn something new.

Re:Tempo: a tiny JSON rendering engine by zdw on Monday March 21, 2011 @10:41AM (#2349874)
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.

Re:Tempo: a tiny JSON rendering engine by d0m on Monday March 21, 2011 @08:00AM (#2349312)
Interesting. At first sight, I couldn't really understand the difference with the existing icanhazjs(.com) library? Can you elaborate on this?
Re:Tempo: a tiny JSON rendering engine by aitorciki on Monday March 21, 2011 @07:49AM (#2349278)
How well does the {{}} syntax coexist with server-side template languages like Django's one which uses the exact same marker for placeholders?
Re:Tempo: a tiny JSON rendering engine by d0m on Monday March 21, 2011 @07:58AM (#2349303)
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 %}
Re:Tempo: a tiny JSON rendering engine by keytoll on Monday March 21, 2011 @03:23AM (#2348822)