Liquid JS

Posted by tobi — 09:54 PM Aug 30

Color me impressed.

Matt Mccray ported Liquid to javascript. Go here to get the gist of it (yea, bad pun)

Pretty awesome work Matt :-)


<script>
 Liquid.readTemplateFile = function(path) {
  var elem = $(path);
  if(elem) {
    return elem.innerHTML;
  } else {
    path +" can't be found."; // Or throw and error, or whatever you want...
  }
 }

 var tmpl = Liquid.parse("{% include 'myOtherTemplate' with current_user %}"); 
 alert( tmpl.render({ current_user:'M@' }));
</script>

<script type="text/liquid" id="myOtherTemplate">
  Hello, {{ current_user }}!
</script>

Comments

  • Kody pocztowe 02 Sep 04:01

    I like it :)

  • Larry Kluger 12 Sep 17:22

    Hi Tobias,

    I don’t know of a better way of contacting you, so here goes:

    Please update README.textile for your Delayed Job package to have create table use field “locked_at” instead of “locked_until”

    —You updated the software but forgot the Readme.

    Thanks very much!

    Regards,

    Larry K

Commenting are now closed…