Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
TWiki Variables | ||||||||
Line: 75 to 78 | ||||||||
You can also set preferences variables on a topic by clicking the link Edit topic preference settings under More topic actions . Use the same * Set VARIABLENAME = value syntax. Preferences set in this manner are not visible in the topic text, but take effect nevertheless. | ||||||||
Added: | ||||||||
> > |
Parameterized Variables (Macros)It is possible to pass parameters to TWiki variables. This is called a macro in a programming language. To define a parameterized variable, set a variable that contains other variables, such as:* Set EXAMPLE = Example variable using %DEFAULT%, %PARAM1% and %PARAM2% * Set DEMO = Demo using %DEFAULT{ default="(undefined)" }%, %PARAM1{ default="(undefined)" }% and %PARAM2{ default="(undefined)" }%A special %DEFAULT% variable denotes the default (nameless) parameter of the calling variable. Variables optionally may list a default="..." parameter that gets used in case the calling variable does not specify that parameter.
To use a parameterized variable (or call a macro), add parameters within the curly brackets, such as:
* %EXAMPLE{ "foo" PARAM1="bar" PARAM2="baz" }% * %DEMO{ "demo" PARAM2="parameter 2" }% -- note that PARAM1 is missingwhich resolves to:
ExampleDefine variables:* Set DRINK = red wine * Set FAVORITE = My %DEFAULT{default="favorite"}% dish is %DISH{default="steak"}%, my %DEFAULT{default="favorite"}% drink is %DRINK%.The default can be defined with a default parameter ( %DISH{default="steak"}% ), or as a preferences setting (Set DRINK = ... ).
Use Variables:
%FAVORITE{ DISH="Sushi" DRINK="Sake" }%Returns: My favorite dish is Sushi, my favorite drink is Sake. %FAVORITE{}%Returns: My favorite dish is steak, my favorite drink is red wine. %FAVORITE{ "preferred" }%Returns: My preferred dish is steak, my preferred drink is red wine. <-- Defined in INCLUDE:
| |||||||
Access Control VariablesThese are special types of preferences variables to control access to content. TWikiAccessControl explains these security settings in detail. | ||||||||
Line: 149 to 165 | ||||||||
Changed: | ||||||||
< < | Related Topics: UserDocumentationCategory, TWikiVariablesSearch, TWikiVariablesQuickStart | |||||||
> > | Related Topics: UserDocumentationCategory, TWikiVariablesSearch, TWikiVariablesQuickStart, ParameterizedVariables |