Let's accept it, sometimes we want very complex things added to Jass but other times, the only thing we actually need is an automatic text copy+paste+replace, textmacros were added because they can be really useful in a lot of very different cases
The syntax is simple, //! textmacro NAME [takes argument1, argument2, ..., argument n] then //! endtextmacro to finish. And just a runtextmacro to run. It is easier to understand after an example:
//! textmacro Increase takes TYPEWORD
function IncreaseStored$TYPEWORD$ takes gamecache g, string m, string l returns nothing
call Store$TYPEWORD$(g,m,l,GetStored$TYPEWORD$(g,m,l)+1)
endfunction
//! endtextmacro
//! runtextmacro Increase("Integer")
//! runtextmacro Increase("Real")
The result of the example is:
function IncreaseStoredInteger takes gamecache g, string m, string l returns nothing
call StoreInteger(g,m,l,GetStoredInteger(g,m,l)+1)
endfunction
function IncreaseStoredReal takes gamecache g, string m, string l returns nothing
call StoreReal(g,m,l,GetStoredReal(g,m,l)+1)
endfunction
The $$ delimiters are required because the replace tokens could require to be together to other symbols.
Notice that strings and comments are not protected from the text replacement. So if there is a match for any of the arguments delimited by $$ it will always get replaced.
textmacros don't need arguments, in that case you simply remove the takes keyword.