This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Install & configuration » A note for those who need to escape...
expandshrink

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

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

Thursday 30 January 2003 6:44:20 pm - 2 replies

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.

Friday 31 January 2003 9: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.

Tuesday 04 February 2003 5:09:45 pm

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

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from