Versions Compared

Key

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

Contents

Table of Contents

Template Language

The template language need appeared in early versions of SIL™. Creating real mail templates was not very easy, and the SIL™ programmer had to resort to all kind of artificial constructs for that. Especially, repetitive constructs were hard to embed in the body of the mail, and they needed to be built in the script before inserting them into the mail, with all necessary escapes, making the process of sending that mail cluttered.

...

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

How It Works 


The idea of the STL is simple:

  1. Template is provided by the user. The user writes embedded code within it.

  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 technique is resembling the JSP (Java Server Pages) technique.

Syntax

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 represented below: 

...

STL Example
Code Block
<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> 

How To Use Them

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.

These two use cases are represented below:

Child pages (Children Display)
excerpttrue
excerptTypesimple

How Do I Edit Templates ?

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

View file
nameInvalid file id - UNKNOWN_MEDIA_ID


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 


For The Technical Minded

In the backstage, SIL defines 3 internal routines:

  • _stl__init()

  • _stl__done()

  • _stl__print()

The following template is translated to the following one:

...

template text
title
Code Block
start
$v$
$! 
if(v == 1) { 
$
inside-if
$!
}
$
end
Code Block
translated SIL unit
Code Block
_stl__init();
_stl__print("start");
_stl__print(v);
if(v == 1) { 
  _stl__print("inside-if");
}
_stl__print("end");
return _stl__done();

...