Wiki Templates

Templates allow you to easy include the full content of a “template” page into another page.

Basic Templates

To create a template, simply create a wiki page whose name starts with “Template”, e.g. “Template Greeting”.

? Title Template Greeting
How are you?

To use a template, include this wiki syntax, which will be replaced with the content of the template page:

{{{= Greeting}}}

You can use a template in the middle of a line if you use two brackets instead of three, but not all wiki formatting is supported.

Our greeting: {{= Greeting}}

Template Parameters

You can supply parameters when invoking a template.

{{{= Greeting|name=Alice}}}

To use the parameter in the template, surround the parameter name in brackets:

? Title Template Greeting
Hello, {name}!
How are you?

Template Example

Basically, a segment, like {{= X }}, or a section, like {{{= X }}}, is replaced by the content of the wiki page with the “Template X” (X is the same in the segment, section, and template name). For an example, see Template Example, which uses Template Sandbox. Those examples also demonstrate the use of parameters (e.g. “name” and “excited”) and macros (e.g. $(if)).

Example Template Code

This is a template, {name}.

It has two paragraphs$(if,$(switch,{excited},y,y),!,.)

Example Segment or Section Code

Templates can also be used inline: “{{= Sandbox|name=Ed}}” Yay!

Example Output

Templates can also be used inline: “” Yay!

Template Scripts

You can write simple scripts in templates using string substitution macros.

$() nothing
$(dollar) dollar sign
$(comma) comma
$(lpar) left paren
$(rpar) right paren
$(comment,arg,…) nothing; arguments are ignored
$(and,arg1,arg2,…) returns the last argument if all arguments are non-empty
$(or,arg1,arg2,…) returns the first non-empty argument
$(not,arg) returns a non-empty string if the argument is empty, and vice-versa
$(if,cond,true) returns ‘true’ if ‘cond’ is non-empty, otherwise the empty string
$(if,cond,true,false) returns ‘true’ if ‘cond’ is non-empty, otherwise ‘false’
$(if,cond1,true1,cond2,true2,cond2,…) returns ‘true1’ if ‘cond1’ is non-empty, otherwise ‘true2’ if ‘cond2’ is non-empty, etc.
$(unless,cond,…) same as $(if,$(not,cond),…)
$(switch,value,test1,result1,test2,result2,…) returns ‘result1’ if ‘value’ is the same string as ‘test1’, etc. A trailing ‘resultn’ with no ‘testn’ will be returned as the default if there is no match to a test.
$(repeat,num,value) evaluates ‘value’ ‘num’ times
$(prop,name) page property (see below)

Use $(prop,name) to get page properties, one-to-one semantic relationships, $(prop,title), $(prop,last-modified-by), $(prop,last-modified-date), $(prop,revision-number), $(prop,created-by), and $(prop,created-date).

Most whitespace is significant, but if a line of wiki text is composed entirely of one macro that results in an empty string, we remove that line, so that this remains one list with two items:

$(if,x,* one)
$(if,,* two)
$(if,y,* three)
  • one
  • three

Macros can span multiple lines. We trim leading whitespace from macro arguments if that whitespace includes a newline, so that this macro works even though there is whitespace before the first template parameter (which would otherwise cause the condition to be true), and so that it doesn’t generate any newlines (e.g. before “Mr.”):

    {firstName} {lastName},
    Mr. {lastName})

Additional macros are defined but not yet implemented: string comparison and manipulation, integer comparison and arithmetic, variables, loops, and custom macros.

Logos Bible Software Wiki

Welcome, Guest! (sign in)