Arguments

When you use variables, you can pass arguments to them:

This

$$hello = {{
Hello, $$Args{}
}}
$$hello{Alex}

Becomes

Hello, Alex

What’s the difference between a variable and a macro? Technically, there isn’t one. We like to refer to simple variables as variables and complex variables that take arguments as macros.

Accessing individual arguments

You can access individual arguments:

This

$$hello = {{
Hello, $$Args[0] and $$Args[1]
}}
$$hello{Alex | Blair}

Becomes

Hello, Alex and Blair

Named arguments

You can name arguments:

This

$$hello = {{
Hello, Mx. $$Args.first{} $$Args.last{}
}}
$$hello{|.first Alex |.last Bobo}

Becomes

Hello, Mx. Alex Bobo

Testing for the presence of arguments

You can change the behavior of a macro based on whether an argument is present:

This

$$hello = {{
$$IfNotEmpty{$$Args.strong{}}
Hello, my good friend $$Args[0]{}
$$Else{}
Hello, $$Args[0]{}
$$EndIf{}
}}
$$hello{Alex}
$$hello{Alex |.strong true}

Becomes

Hello, Alex
Hello, my good friend Alex

Testing for the number of arguments

You can use $$IfNumArgs to change the behavior of a macro based on how many arguments are passed to it:

This

$$hello = {{
$$IfNumArgs{1}
Hello, $$Args[0]{}
$$ElseIfNumArgs{2}
Hello, $$Args[0]{} and $$Args[1]{}
$$EndIf{}
$$hello{Alex}
$$hello{Alex | Blair}

Becomes

Hello, Alex
Hello, Alex and Blair

Next: Other Commands