Forums / Install & configuration / A note for those who need to escape the character "{" in templates

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.)

eZ debug

Timing: Jan 18 2025 02:11:35
Script start
Timing: Jan 18 2025 02:11:35
Module start 'content'
Timing: Jan 18 2025 02:11:35
Module end 'content'
Timing: Jan 18 2025 02:11:35
Script end

Main resources:

Total runtime0.9476 sec
Peak memory usage4,096.0000 KB
Database Queries196

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 589.2031180.7891
Module start 'content' 0.00710.7939 769.9922593.8438
Module end 'content' 0.80090.1466 1,363.8359336.7188
Script end 0.9476  1,700.5547 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.4664210.0002
Check MTime0.00160.1636210.0001
Mysql Total
Database connection0.00110.118110.0011
Mysqli_queries0.869791.78131960.0044
Looping result0.00180.19141940.0000
Template Total0.916096.720.4580
Template load0.00210.225620.0011
Template processing0.913996.438320.4569
Template load and register function0.00030.028110.0003
states
state_id_array0.00100.102410.0010
state_identifier_array0.00160.172220.0008
Override
Cache load0.00170.1831500.0000
Sytem overhead
Fetch class attribute can translate value0.00130.135740.0003
Fetch class attribute name0.00100.101350.0002
XML
Image XML parsing0.00300.320640.0008
class_abstraction
Instantiating content class attribute0.00000.000950.0000
General
dbfile0.00540.5727340.0002
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs