Site:Frontend:Macros
From Metrixstream
(Difference between revisions)
MetrixJustin (Talk | contribs) (Created page with "=== Introduction === Macros are the Clearsilver equivalent to functions. Macros let you define a block of code that can be re-used throughout the site. === Creating a Macro ==...") |
MetrixJustin (Talk | contribs) (→Creating a Macro) |
||
Line 13: | Line 13: | ||
With macros there is no returning specific data, anything in the macro will be placed where its called. | With macros there is no returning specific data, anything in the macro will be placed where its called. | ||
− | |||
=== Macro Parameters === | === Macro Parameters === |
Revision as of 12:54, 15 June 2012
Introduction
Macros are the Clearsilver equivalent to functions. 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.