STT - Smalltalk Templates
Last updated at 5:33 pm UTC on 16 January 2006
Last revision: 13/Jul/2002
Author: Federico G. Stilman - Thanks to Diego Gomez Deck for the idea!
Project Description
The same way ASP, JSP, PHP, etc. do it, STT's idea is to make possible to write Smalltalk code within the context of an HTML, or any kind of document. For instance,
This is number {%= 5 + 2 %}, and this are repeating words:
{% 10 timesRepeat: [ %}
ThisIsARepeatedWord
{% ] %}
is a simple template that STT can process to produce some output.
Status
- 6/Jul/2002: project started
- 7/Jul/2002: First version is out. Basic STT scripting works fine.
- 8/Jul/2002: Added simple STTModule for Comanche to serve dynamic content via STT. Some bugs fixed and TODO's done.
- 9/Jul/2002: STTTemplates are now compiled only once. Simple implementation of a cache of requested templates on STTModule.
- 10/Jul/2002: rST - Remote Smalltalk's Cache class is used for template caching (see Required Files on Download)
- 12/Jul/2002: Method #asStringSelector (#asStringSelector:) now specifies the message to be send to objects that show themselves on generated templates (with =). Defaults to #asString.
Download
How to use
The following code will generate a #test template sending the resulting String to a file named testFile.
See class methods in category "examples" for more information.
f := FileStream newFileNamed: 'testFile'.
f nextPutAll: STTTemplate test.
f close
Known problems of this version
- defining temporary variables on a template cause syntax errors in compilation
- (add problems here)
TODO List
- Handle Errors in 2 alternatives ways (dgd)
- Open the debuger (just like now)
- Catch the exception and put it in the String result
- CompiledMethod>>valueWithReceiver:arguments: spends a lot of time removing the selector just added to receiver class.
DONE List
- Period anymore necessary at the end of ST expressions
- Source code is generated only once and then cached
- Comanche Integration: STTModule adds dynamic content capabilities without adding any more dependencies to the STT core (basic in functionality)
- aCompiledMethod is cached instead of ST source code (BIG performance gain)
- STTModule now caches templates per URL
- rST's cache implementation class used (Cache)
- Added #asStringSelector (and associated instance creation facilities) for specifying the message to be send to objects that need to show themselves on a generated template. Defaults to #asString.
STT Ports to other Smalltalks