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.