smarty: curly brackets in argument

it is a well-known problem that curly-brackets in a smarty function-argument make the script die with an error. this is because the curly-bracket is part of the smarty-tagging. unfortunately there is no escaping possible. also the {literal} is not useful, because it can only be used for document-content, like JavaScript or CSS.

example:

{$foo|regex_replace:"/^([0-9]{4})([0-9]{2})([0-9]{2})$/"
:"$3.$2.$1"}

dies with an error.

workaround:

{capture assign=foo_regex}{literal}/^([0-9]{4})([0-9]{2}
)([0-9]{2})$/{/literal}{/capture}
{$foo|regex_replace:$foo_regex:"$3.$2.$1"}

does the trick.

source:
smarty-forum-post

Sunday, 24. September 2006 • trackback url

Add Comment

( to reply to a comment, click the reply link next to the comment )

Comment Title:
Your Name:
Email Address:
Make Public?
Website:
Make Public?

Comment:


Allowed XHTML tags : a, b, i, strong, code, acrynom, blockquote, abbr. Linebreaks will be converted automatically.


Captcha:

captcha image

please type the content of the above image into the following form-field: