Custom template tag (like {literal}) possible?

Author Message

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:20:54
Script start
Timing: Jan 18 2025 02:20:54
Module start 'layout'
Timing: Jan 18 2025 02:20:54
Module start 'content'
Timing: Jan 18 2025 02:20:55
Module end 'content'
Timing: Jan 18 2025 02:20:55
Script end

Main resources:

Total runtime0.6768 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 589.4922152.6406
Module start 'layout' 0.00530.0027 742.132839.4844
Module start 'content' 0.00790.6673 781.6172583.7813
Module end 'content' 0.67530.0015 1,365.398412.1250
Script end 0.6768  1,377.5234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4876160.0002
Check MTime0.00140.2012160.0001
Mysql Total
Database connection0.00060.093810.0006
Mysqli_queries0.627692.7225600.0105
Looping result0.00060.0867580.0000
Template Total0.650296.120.3251
Template load0.00180.271020.0009
Template processing0.648495.799120.3242
Template load and register function0.00030.042110.0003
states
state_id_array0.00070.108610.0007
state_identifier_array0.00070.106220.0004
Override
Cache load0.00150.2200210.0001
Sytem overhead
Fetch class attribute can translate value0.00060.082630.0002
Fetch class attribute name0.00100.141850.0002
XML
Image XML parsing0.00140.203330.0005
class_abstraction
Instantiating content class attribute0.00000.001850.0000
General
dbfile0.00100.1435250.0000
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs