5 ms·
Google's Templating Language
- evan_ 15y agoProbably explains why, when you search for ${, google explodes.
- dfrankow 15y agoMore detail?
- coderdude 15y agoIt's #1 on the front page right now.
- jfarmer 15y agoMaybe, but it doesn't look like $ is a special character.
- evan_ 15y agohaha, you're right- I saw "${{value}}" and thought it was the delimiter- but no, it actually prints $50 or whatever.
- dsl 15y agoNo, thats a JavaScript bug.
- grandalf 15y agoaka mustache {
- thurn 15y agoPretty surprising how needlessly different this is from their soy templating language: http://code.google.com/closure/templates/ http://code.google.com/closure/templates/
- buff-a 15y agoIt emphasizes separating logic from presentation: it is impossible to embed application logic in this template language. StringTemplate for C++ then. http://www.stringtemplate.org/ http://www.stringtemplate.org/ Its distinguishing characteristic is that it strictly enforces model-view separation unlike other engines. Strict separation makes websites and code generators more flexible and maintainable; it also provides an excellent defense against malicious template authors.
- judofyr 15y agoYou forgot the best part of StringTemplate: Terence Parr has even written a paper about it where he discusses some difficulties and solutions: http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf
- SimHacker 15y agoFighting against malicious template authors is a losing battle I don't want to fight. I simply won't hire or work with somebody I consider malicious, and don't trust the general public to write templates for my system. Zope tried that with "safe python" and TAL/TALES/METAL, and it was an utter abortion.
- huhtenberg 15y agoIs this really Google's?
- simpsond 15y agoYup. Look at the source for copyright information.
- skrebbel 15y agoSo someone almost ported Mustache. Makes me wonder: are the differences historical (e.g. the projects didn't know of it each other until well evolved), or are there good (C++-related?) reasons for the slightly different syntax?
- nostrademons 15y agoCausation runs the other way. Mustache is a port of cTemplate. cTemplate has been around internally since the early 2000s (look at the author: it's Craig Silverstein, Google's employee #1) and was open-sourced in 2008, while Mustache is (c) 2009 and explicitly lists cTemplate as an influence.
- skrebbel 15y agoAh right. I stand corrected.
- haunt 15y agoActually, Mustache is a "ripoff" of ctemplate with a gay name.
- benatkin 15y agoThe Closure Templates project is much more interesting IMO. http://code.google.com/closure/templates/ http://code.google.com/closure/templates/ They can be used server-side on the JVM, or client-side (compiled on the server side). They're pretty fast. I wish template engines would have URL sanitization functions built into them (that remove javascript: and other URI schemes). I thought Closure Templates might have when I saw escapeUri, but it doesn't. (The similar-sounding esc_url in WordPress does remove javascript: and other problematic URI schemes.) User-submitted URLs should be sanitized, but it wouldn't hurt to have another layer of security when they are, and it would help when they aren't. I blogged about this: http://benatkin.com/2011/09/16/safe-html-from-a-template/ http://benatkin.com/2011/09/16/safe-html-from-a-template/
- js4all 15y agoClosure Templates was also my first thought. I like them a lot and have combined them server-side with AppJet, which also runs on the JVM. A perfect match in my opinion. I have written a blog post about this: http://blog.jgate.de/closure-templates-for-appjet http://blog.jgate.de/closure-templates-for-appjet