More on setting macros

Setting macros

When we use $(set:name=...), the value of the macro extends all the way before last closing parenthesis. This is convinient as we can set almost arbitrary values without any special handling, albeit maybe ugly.

page: t
    $(set: name=Long line with "quotes" and (parentheses) and even unbalanced ones }))


Long line with "quotes" and (parentheses) and even unbalanced ones })

In addition, both the name part and value part may contain macros, even nested ones.

    A1: macro A1
    A2: macro A2

page: t
    $(set:$(name)_1=set $($(name)1).)
    $(set:$(name)_2=set $($(name)2).)


set macro A1.
set macro A2.

$(export:...) and $(setmacro:...) works the same way.

Spliting macros

$(split:name) splits macro $(name) into $(p_1), $(p_2), ...

    a_list: a, b, c, d, e, f

page: t
    a_list[6]: $(p_6)


a_list[6]: f


$(unset:name) will delete all macros with "name" at all scopes. Use carefully.

    name: Hui

page: t
        Hello, $(name)

        Still here!
        Oh, you are no longer here!


Hello, Hui                 
Oh, you are no longer here!


$(autoinc:name) will set a macro at page scope starting with value 1. Each time this statement is encoutered, it increase the value by 1.

subcode: A
    var A_$(index);

page: t
    $(for:i in 1..10)
        $call A


var A_1;  
var A_2;  
var A_3;  
var A_4;  
var A_5;  
var A_6;  
var A_7;  
var A_8;  
var A_9;  
var A_10;

results matching ""

    No results matching ""