Forums / Developer / Custom template tag (like {literal}) possible?
Markus Birth
Thursday 23 June 2011 3:10:00 am
Hi, there,
I'm thinking about building a CoffeeScript-extension which should allow you to add CoffeeScript in templates between {coffee}…{/coffee} tags. While compiling the template, the CoffeeScript should also be compiled to JavaScript and stored as JavaScript in the compiled template.
I looked around the eztemplate classes but found no real starting point. (Are there .ini-settings needed? Autoloads? etc.)
Any hints?
Cheers,
-mARKUS
André R.
Thursday 23 June 2011 4:30:55 am
Nope, eztemplate is black magic when it comes to these things, as it's two separate code paths for compiled and interpreted mode. If you survive to tell the tale we'll buy you a cookie :)But! Template-blocks are hardcoded into the parsers, so it is AFAIK not something you can extend from extensions. So if I where you I would try to go another route on this one, at least until we have changed our template engine to something else.
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription @: http://twitter.com/andrerom
Marko Žmak
Thursday 23 June 2011 1:13:23 pm
Well one way to do it would be to create a custom template operator to which you will pass the CoffeScript code, and which will then generate the desired output.
P.S. In case you wondered, strings in eZP template can be multiline.
-- Nothing is impossible. Not if you can imagine it! Hubert Farnsworth