5 ms·
This is so wrong headed I don't even know where to begin. You couldn't even begin to localize templates like this without rewriting them. Good luck modularizing
by spullara 14y ago
This is so wrong headed I don't even know where to begin. You couldn't even begin to localize templates like this without rewriting them. Good luck modularizing the code as well. Stick with mustache[1]. There are very good reasons to not use something like walrus.js that you don't understand when you are starting your app that will become very much apparent when you are trying to finish it.
[1] I am the creator of mustache.java
- GertG 14y agoI appreciate that you can't go far into technical details in an HN comment, but after a statement like that, you could at least give a pointer to those "good reasons". They might not be as obvious to everyone as you assume.
- Xylakant 14y agoSince I can't peek into the OPs head, I'll have to speculate but here's my take: The power of Mustache (and Handlebars) was that it forced you to write logic-less templates. There's just no way to express logic other than checks for existence of values. That means that you have a minimal language that every non-programmer [1] can understand. You can change templates without diving into a language. Walrus changes that to be a pretty much full featured template language with full view logic (hey, look, there's MATH methods in there). It perverts the idea of Mustache. [1] aka designer or template-guru :)
- spullara 14y agoThanks, you read my mind.
- tijs 14y ago"You couldn't even begin to localize templates like this without rewriting them" How come? If your base HTML templates are say python or ruby templates they could be localized fine. And if the JSON content your parsing with Walrus comes from the same backend and is also localized where's the issue? It's mustache with some view logic sugar which makes a lot of sense as far as i'm concerned and would allow your HTML templates to be mostly 'logic free'.
- zzzeek 14y agowhat language/locale does the "time ago in words" (http://documentup.com/jeremyruppel/walrus/#walrus-dates/time_ago_in_words http://documentup.com/jeremyruppel/walrus/#walrus-dates/time...) function return a result in ? Looks pretty hardcoded: https://github.com/jeremyruppel/walrus/blob/master/lib/walrus.dates.coffee#L161 https://github.com/jeremyruppel/walrus/blob/master/lib/walru...
- jeremyruppel 14y agoi18n support has been on the roadmap for some time. Just haven't needed it/had the time for it yet. https://github.com/jeremyruppel/walrus/issues/19 https://github.com/jeremyruppel/walrus/issues/19 Contributions always welcome :)
- kapowaz 14y agoConversely, my experience is that there are very good reasons not to use Mustache (and instead use Handlebars etc.) — there are just too many limitations that force you to push commonly required functionality into an awkward place within the application stack. Plus there's the whole thing that ‘logic-less’ is a big white elephant: templates need logic, or they quickly become unmanageably bloated and un-DRY. Being able to iterate and conditionally branch are fundamentals essential to templating languages, and so whilst Mustache is an interesting starting point, it's usually not the best solution. Of course, the one benefit Mustache does have is parsers in lots of languages, allowing you to share templates across client and server-side — it'd be great if somebody were to invest time in producing (say) a Ruby version of Walrus, as it looks like a very useful tool from reading through the docs.
- moe 14y agoI agree wholeheartedly. Logic-less templates are a red herring and I cringe every time I enter a project where someone has drunken the Kool-Aid. There's the rare fringe use-case where logic-less templates make sense, e.g. when you need to accept templates from untrusted sources (user editable) or when you really can re-use them across tiers to a significant degree. In pretty much all projects neither is the case. Instead, they quickly turn into a ball on a chain that constantly gets in the way and causes more problems than it solves. This is my experience from encountering them in nearly a dozen projects and from having fallen for the temptation more than once myself.
- laserDinosaur 14y ago"templates need logic, or they quickly become unmanageably bloated and un-DRY" Maybe I'm misunderstanding this, but you can do some fancy stuff with handlebars.js. You can 'foreach' through a json collection right in the template, 'if' 'else' statements and a whole whack of other cool little logic statements. So far I've not found anything I can't do in handlebars that I could do generating the page server side. Maybe I'm missing some more advanced cases or misunderstanding the term 'logic-less'?
- kapowaz 14y ago