Normally, variables assigned within a template would
be visible globally. With local
instructions, variables assigned
within a local block would be visible only within the block.
Local instructions can be declared as:
<local> ...some template code... </local>
In the next example, all variables assigned within the block are only visible within the block:
<assign message = "the global message"> <local> <assign url = link.url> <assign image = link.image> <assign message = "the local message"> <a href="${url}"> <if preferences.showImages> <img src="${image}" border="0" alt="${message}"> <else> ${message} </if> </a> </local> ...some HTML... Variable message is the global message.
In this example, only the variables named in the brackets are scoped locally:
<assign message = "the global message"> <local (url, image)> <assign url = link.url> <assign image = link.image> <assign message = "the local message"> <a href="${url}"> <if preferences.showImages> <img src="${image}" border="0" alt="${message}"> <else> ${message} </if> </a> </local> ...some HTML... Variable message is the local message.
Previous: Transformations | Next: Whitespace |