Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


On this page:

Table of Contents

The Need for a Template Language

...

The first step in creating a real template language was done with the (unpublished) add-on app SIL on-the-fly Reporter, at version 3.x. However, this initial development was aimed at that add-on app only, and in version 4.x a substantial effort has been employed to put STL at the base of the add-onsapps, near SIL so it can be used from all the places and all add-onsapps.

 

That being said, STL (SIL Template LanguageSIL Template Language) should not be confounded with C++ STL (Standard Template Library). They are different beasts.

...

  1. Template is provided by the user. Within it, the user writes embedded code.
  2. The code is translated into a fully executable SIL script, buffered in memory.
  3. The SIL interpreter is called on the given script; the script is executed and the result is gathered in a special area, in memory.
  4. The result is retrieved and used wherever is needed.

...

The syntax used is backward compatible with the previous versions of templates, so you can expand the use of STL immediately over your old templates.

 

Token(s)
Explanation
STL Example
$!expression$Translates the expression into SIL exactly as it is$!for (number i = 0; i<o; i++) $
$output$outputs the string expression in the result$assignee$
\$the $ character ($ needs to be escaped now)\$

 

An example is presented represented below:

 

Code Block
titleSTL Example
<html>
<body>
Hello $reporter$ from $custName$, the sender $sender$ announces you that the assignee for issue $key$ is $assignee$ and that work has started
$!
//this is a simple script, not carrying too much meaning, but just used as an example.
for(number i = 0; i < 3; i++) {
    $
    <p>
        Hooray!
    </p>
    $!
}
$
</body>
</html> 

...

The scripting usage is simple. You can use STL to create template emails or directly in your programs you may call the executeTemplate() routine to parse and execute a template.

...

You can access your templates from the "SIL Manager" page page, by selecting the " Kepler Home" tree Home tree view:

 

Note

As of now, the SIL Manager does not have proper support for checking the STL syntax. We're working on it, but it may take a while.

...

In the backstage, SIL defines 3 internal routines:

  • _stl__init()

...

  • _stl__done()

...

  • _stl__print()

...

The following template:

Code Block
titletemplate text
start
$v$
$! 
if(v == 1) { 
$
inside-if
$!
}
$
end

...