Versions Compared

Key

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

Table of Contents

...

Template Language

 

The necessity for a template language 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.

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

 

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 at the base of the STL is simple:

...

As you can see, the technique is resembling the JSP (Java Server Pages) technique, so it's nothing spectacularexciting.

 

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.

...

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 presented hererepresented below:

Child pages (Children Display)
excerpttrue
excerptTypesimple

...

Execution will append the result of the print statements in a buffer kept as a local execution variable in the SIL context, so once the script has finished, it is ready the unnecessary to be garbage collected. 

Info

In fact, STL is pluggable and doesn't care about depend on these exact symbols. The generator can use different separators and different routine names. However, the bridge between STL and SIL have defined them as stated above.

...

Note

Don't create very large templates. We do not see the need right now for very large templates. If you need such templates, let us know.