Liquid templates announced
Posted by tobi November 06, 2005 @ 07:14 PM
Liquid is a brand new template engine optimized for xhtml and emails. It features a very clean syntax and speedy execution speeds. The main difference to traditional ERb is that it does not rely on eval. This means that no potentially harmful code is executed when a Liquid template is compiled or rendered.
The chief advantage is that you can let your users change templates without having to worry about your data’s security. The templates only see data which you export to them. In Shopify for example you will be able to edit your shop’s templates and emails directly in the admin interface. The templates are stored in the database and rendered directly from it.
Liquid is packaged as a rails plugin for easy installation. In good rails style there is a small movie available showing how to install and use it.

Very cool; thanks Tobias!
I’m so glad to see this. Will help a lot of people who are building sites with dynamic content for their users but don’t want their users to break anything.
welcome :)
Well the first negative comment here. I’m glad they released it as an alternative, but, unlike erb, it doesn’t allow pure ruby code in it. It’s like putting one interpreter inside another; in the end it slows everything down and causes more confusion.
Michael,
That’s why it exists. So that you can’t put ‘pure ruby code’ in it… It’s not confusing… there is a specific purpose for it. :-)
Michael gets two thumbs up for skipping paragraph two of the article.
I agree that you probably don’t want to use liquid during normal operation though. Not yet anyways.
Very nice, I have a perfect use for this I believe.
Thanks tobias, hope one day we all can contribute as much to the community.
Very nice, I have a perfect use for this I believe.
Thanks tobias, hope one day we all can contribute as much to the community.
I find that I can’t put Ruby code in presentation layer a plus, not a negative.
If you didn’t specify layout ‘demo’ would Rails default to the demo.liquid? Or would the fact that it isn’t a traditional .rhtml layout a problem?
Some hidden features there :) .... 11 def parse(tokens) 12 @nodelist ||= [‘wtf’] 13 @nodelist.clear ....
OK, I am still a bit new ot R(oR) . . . that’s my excuse for the following question.
Where is the plugin tool? The list below is the only thing in my script directory: 02-11-2005 09:08 <dir> . 02-11-2005 09:08 <dir> .. 02-11-2005 09:08 112 breakpointer 02-11-2005 09:08 107 console 02-11-2005 09:08 107 destroy 02-11-2005 09:08 108 generate 02-11-2005 09:08 <dir> performance 02-11-2005 09:08 <dir> process 02-11-2005 09:08 106 runner 02-11-2005 09:08 106 server
I am used to PHP with Smarty, so Liquid is interesting to me.
The above describes how to get the plugin script (linux/mac, no windows , yet)
Very nice!
How does javascript (or rails javascript helpers) fit into the Liquid system? Is it possible to have a relatively ‘clean’ layout with big, nasty ajax calls pulled in from elsewhere?
Awesome contribution again tobi! This is going to make a very nice substitute for my hackish gsub templates.
Great work!
Grrrreat! – this for me is the missing part of Rails.
This makes it much easier when distributing tasks amongst designers with a little XHTML experience and Ruby/Rails coders however…
I like the idea of XML style tags similar to those used in WACT (a php framework eek!).
I can change the variable references to look more like
{$variable}by simply modifying the liquid.rb file, however something like:<core:optional for="variable">Some text</core:optional>is proving to be a little move involved due to the Regexp parser. Does anyone have any ideas how to accomplish this without hacking to code around too much or would it need a lexer?
I basically need XML markup for the blocks and variable references as they are. More examples of what I mean: http://www.phpwact.org/wact/template_authors_guide?DokuWiki=c1b0a7441969f8e9cca893f9752f1a6f (list tags are quite nice too).
does this system allow to use partials, partialls controllers, and ajax calls. as rails native manage ? i ask because i like the idea of xhtml design but want to heavily use partials. helpers, controllers and ajax calls