A note for those who need to escape the character "{" in templates

Author Message

Volker Lenz

Thursday 30 January 2003 9:44:20 am

If you are using javascript functions or inline style-declarations in your page layout templates, you will have faced the problem of how to escape the character "{", so that the ezp template parser won't destroy e.g. the opening brackets of your javascript functions.
The recommended way to accomplish this is to use the "{literal}" and "{/literal}" operators. However, these operators are buggy in ezp3-rc1.

Another way that does the job without using "{literal}" is using "{ldelim}" and "{rdelim}" where you want to get "{" and "}" in your template output. "{ldelim}" and "{rdelim}" are internal functions of the ezp template parser. These functions let the parser print out just the parser-tags it uses.

There is one little caveat to keep in mind when you use the "{ldelim}" and "{rdelim}": If the ezp-devs should actually decide to use another standard tag instead of "{" and "}" for their template parser, you will have to change your own templates, too, since "{ldelim}" and "{rdelim}" will always print out the parser tag in use, and if this tag should be changed to say "{#", your javascript-functions will also get an "{#" as opening bracket.

However, this seems not to be a serious danger for template designers, since most of you are probably using an editor tool capable of replacing text chunks as needed. So if some day the "{ldelim}" and "{rdelim}" are no longer appropriate, we may easily change them to whatever may be appropriate then.

Jan Borsodi

Friday 31 January 2003 12:49:25 am

> If you are using javascript functions or inline
> style-declarations in your page layout templates, you will
> have faced the problem of how to escape the character "{",
> so that the ezp template parser won't destroy e.g. the
> opening brackets of your javascript functions.
> The recommended way to accomplish this is to use the
> "{literal}" and "{/literal}" operators. However, these
> operators are buggy in ezp3-rc1.
>
> Another way that does the job without using "{literal}" is
> using "{ldelim}" and "{rdelim}" where you want to get "{"
> and "}" in your template output. "{ldelim}" and "{rdelim}"
> are internal functions of the ezp template parser. These
> functions let the parser print out just the parser-tags it
> uses.
>
> There is one little caveat to keep in mind when you use the
> "{ldelim}" and "{rdelim}": If the ezp-devs should actually
> decide to use another standard tag instead of "{" and "}"
> for their template parser, you will have to change your own
> templates, too, since "{ldelim}" and "{rdelim}" will always
> print out the parser tag in use, and if this tag should be
> changed to say "{#", your javascript-functions will also get
> an "{#" as opening bracket.
>
> However, this seems not to be a serious danger for template
> designers, since most of you are probably using an editor
> tool capable of replacing text chunks as needed. So if some
> day the "{ldelim}" and "{rdelim}" are no longer appropriate,
> we may easily change them to whatever may be appropriate
> then.

The preffered method for getting { in the template is to use the {literal} tag, it will work when RC2 gets out the door (which should be quite soon).
Using {ldelim} and {rdelim} will work too since we have no intention of changing them into other delimiter characters, the reason for having them configurable is when eztemplate is used outside of eZ publish and one is interested in having other delimiter characters.

The third option to getting javascript in template is to place them in separate .js files and use HTML tags to include them.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Jeroen van Gorkum

Tuesday 04 February 2003 8:09:45 am

> The third option to getting javascript in template is to
> place them in separate .js files and use HTML tags to
> include them.

...which is the preferred method in xhtml anyway, to work around problems with '<!--', '-->', '<' and '&' in the page itself. (see Script and Style elements: http://www.w3.org/TR/xhtml1/#h-4.8, and http://doxdesk.com/personal/posts/wd/20010911-cdata.html.)

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 05:21:21
Script start
Timing: Jan 18 2025 05:21:21
Module start 'layout'
Timing: Jan 18 2025 05:21:21
Module start 'content'
Timing: Jan 18 2025 05:21:22
Module end 'content'
Timing: Jan 18 2025 05:21:22
Script end

Main resources:

Total runtime0.9290 sec
Peak memory usage4,096.0000 KB
Database Queries59

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 588.3984152.6875
Module start 'layout' 0.00600.0044 741.085939.5234
Module start 'content' 0.01030.9171 780.6094588.7188
Module end 'content' 0.92740.0015 1,369.328116.0781
Script end 0.9290  1,385.4063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3544160.0002
Check MTime0.00130.1423160.0001
Mysql Total
Database connection0.00090.093110.0009
Mysqli_queries0.868693.4973590.0147
Looping result0.00070.0741570.0000
Template Total0.893096.120.4465
Template load0.00210.228820.0011
Template processing0.890895.891020.4454
Template load and register function0.00010.012910.0001
states
state_id_array0.00080.086110.0008
state_identifier_array0.00160.169120.0008
Override
Cache load0.00190.2002500.0000
Sytem overhead
Fetch class attribute can translate value0.00100.107830.0003
Fetch class attribute name0.00140.150450.0003
XML
Image XML parsing0.00130.141930.0004
class_abstraction
Instantiating content class attribute0.00000.001150.0000
General
dbfile0.00100.1061230.0000
String conversion0.00000.005340.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.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: 6

Time used to render debug report: 0.0001 secs