The Templet language was developed initially as a server-side scripting language for generating HTML. However, it is suitable for client-side scripting as well, although availability of the client-side plug-in will follow availability of the rest of the system.
As a standalone system, Templet is suitable for many other text generation and string processing tasks, including XML processing. It is, in fact, a complete general-purpose programming language.
Templet was designed to integrate well with HTML and derives its main syntactic features from HTML. The principal driving force for Templet 1.0 was to make it as easy as possible for HTML developers to initially use a small set of Templet features that mimicked HTML features. As Templet has evolved, it has grown somewhat more complex, but the essential principle of HTML similarity remains. In particular
which uses the built-in Template functions
Today is [today], [shortdate].
shortdateand substitutes their results in the text, generating, for example
Today is Monday, 10/26/98.
[sum 3 4] => 7
/name. So does Templet, for example
I [if ([user] == Hillary)] <b>really</b> [/if] love you.
unless the user is Hillary, in which case it displays
which will display
[foreach Sandi|Andee|Kathleen] I loved [$].<br> [/foreach]
A local variable could have been used to store the list of names, so the display above could also have been generated by
Adding optional clauses provides even more power:
[do &names = Sandi|Andee|Kathleen] [foreach &names] I loved [$].<br> [/foreach]
[foreach Sandi|Andee|Kathleen][:trim][:separate ", and "] I loved [$] [/foreach]!
I loved <SELECT> [foreach Sandi|Andee|Kathleen] <OPTION VALUE="[$]">[$] [/foreach] </SELECT>
Database extraction is almost as easy. The
function uses standard SQL, except the SQL itself can be dynamically
generated in the same way that other text is. To display all
marriages recorded in the
in the past year, write:
[do &cutoff = [date]; &cutoff.year--; ] [DB.SELECT husband, wife, marrydate FROM Marriages WHERE marrydate > [&cutoff] ] [$husband] was married to [$wife] on [$marrydate].<br> [/SELECT]which could generate
<TABLE BORDER=1 CELLSPACING=1> <TR> [foreach Husband|Wife|Date] <TD><B>[$]</B></TD> [/foreach] </TR> [do &cutoff = [date]; &cutoff.year--; ] [DB.SELECT husband, wife, marrydate FROM Marriages WHERE marrydate > [&cutoff] ] <TR> [foreach [$husband]|[$wife]|[$marrydate]] <TD>[$]</TD> [/foreach] </TR> [/SELECT] </TABLE>could generate
|Joe Johnson||Tillie Tillson||June 14, 1998|
|Sam Samuels||Joan Jolson||August 19, 1998|
|Pete Peters||Sandi Sanders||September 4, 1998|
The Templet 3.0 design is distinguished by the following features:
Templet comes with a wide variety of built-in and library classes, including Class, Object, String, List, Dictionary, SortedList, SortedDictionary, Date, Time, Timestamp, Function, Environment, Conductor, Promise, LazyList, Enumeration, Stream, PatternMatcher, Thread, Lock, Database and Query.
Templet also includes classes that provide significant server-side functionality and web support, including transparent construction of URLs for links, (frame & image) sources, and forms. Exercising these URLs invokes specified server-side Templet functions, passing along request-specific values and/or automatically generated session-id's, which are either encoded in the URL or provided via cookies. These classes also provide functions that simplify construction of input elements, especially those with dynamically-determined initial values.
As a web-driven back-end, Templet can either run as a Java servlet or as a separate Templet server, depending on a servlet, other server plug-in or CGI program to pass appropriate HTTP requests on to the Templet server; other configurations can be readily supported.
Templet's built-in functions are implemented in Java; user-defined functions can be implemented in Java as well. Public Java API's for all Templet object are available for use within user-defined functions.
There is no present support for a security model. Currently we assume that all code is server-side and open. Any access controls (e.g. private fields) are to support programming safety rather than security.
For more information on Templet's features, see
You can also find out about the history of Templet.
Contact Ellis S. Cohen (email@example.com) for more information on availability or on how you can participate in the implementation.