Site:Frontend:Macros
From Metrixstream
Introduction
Macros are the Clearsilver equivalent to functions.... almost. They only produce output to the browser rather than supplying a return value. Because of this the term macro is a more suitable name. Macros let you define a block of code that can be re-used throughout the site.
Creating a Macro
Macros are made by starting and ending a new clearsilver block with def.
<?cs def:getUsername() ?> <?cs var:MS.site.auth.username ?> <?cs /def ?>
With macros there is no returning specific data, anything in the macro will be placed where its called.
Macro Parameters
You can pass parameters into the macro by setting them after the macro name
<?cs def:getUsername(user) ?> <?cs var:user.username ?> <?cs /def ?>
This macro requires the user parameter to generate the username.