Changes between Initial Version and Version 1 of uste/ParserSyntax


Ignore:
Timestamp:
02/03/13 14:09:41 (11 years ago)
Author:
ph3-der-loewe
Comment:

BEGIN{}

Legend:

Unmodified
Added
Removed
Modified
  • uste/ParserSyntax

    v1 v1  
     1[[TOC]] 
     2 
     3= uste parser syntax = 
     4This page describes the syntax of the parser module of libuste. This syntax is used within all templates (as parsed by libuste). 
     5 
     6== Introduction == 
     7The parser reads the document and scans it for commands. uste commands start and end with 3 @s (@@@cmd@@@) while in "document" mode. with the ''pragma'' command you can switch into "uste" mode which will allow you to skip them. This is used to allow bigger blocks to be more easy to read. 
     8 
     9Here is an example in document mode: 
     10{{{ 
     11@@@set answer to 42@@@ 
     12Answer is: @@@var answer@@@ 
     13}}} 
     14 
     15This is an example in uste mode: 
     16{{{ 
     17@@@pragma code uste@@@ 
     18 set answer to 42 
     19 literal: Answer is: 
     20 var answer 
     21 literal special newline 
     22@@@end@@@ 
     23}}} 
     24 
     25So software like web servers can detect the file to be a uste template there is the uste magic number. This magic is the special command ''TEMPLATE'' (@@@TEMPLATE@@@). This magic should be used at the begin of each template so it can be detected by such software. This special command is stripped while rendering and will not generate any output. 
     26 
     27== Basic command syntax == 
     28Each command is started and ended with ''@@@'' if not in uste mode. The first word of the command is the command name. In addition command parameters can follow. After the parameters there can be the ''extra'' parameter which is always a string literal. 
     29So the basic syntax is: 
     30{{{ 
     31@@@command[ ARG[ ARG[ ARG...]]][: extra]@@@ 
     32}}} 
     33 
     34A simple example is setting a variable to a string: 
     35{{{ 
     36@@@set var: string@@@ 
     37}}} 
     38 
     39The number and type of arguments as well as the usage of extra depends on the command. 
     40 
     41== Block commands == 
     42There are some ''block commands''. Those commands are control structures e.g. loops or scopes. Those blocks start with the block command and end with the special ''end'' command like this: 
     43{{{ 
     44@@@if defined a@@@ 
     45a is: @@@var a@@@ 
     46@@@end@@@ 
     47}}} 
     48 
     49It is also possible to end the block with a bang version of the command: 
     50{{{ 
     51@@@if defined a@@@ 
     52a is: @@@var a@@@ 
     53@@@!if@@@ 
     54}}} 
     55However this syntax is more uncommon yet it may be useful when using complex nesting within the template (document mode) with only few or no line breaks. 
     56 
     57== Commands == 
     58=== Normal commands === 
     59=== Block commands ===