eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Comanche::STTTemplate':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: STTTemplate (in Comanche)


Inheritance:

   Object
   |
   +--Comanche::STTTemplate

Package:
stx:goodies/webServer/comanche/stt
Category:
Comanche-STT
Version:
rev: 1.27 date: 2004/09/16 13:07:47
user: ca
file: STTTemplate.st directory: goodies/webServer/comanche/stt
module: stx stc-classLibrary: stt
Author:
Federico Gregorio Stilman

Description:


STT (Smalltalk Templates) support. 
Enables embedding Smalltalk code in HTML and other documents too.

I'm a Smalltalk Template. 
My escaping sequence for embedding Smalltalk expressions is: {% %} or {%= %}.

CG:
    I changed these to <?stt ... ?>
    and                <?stt= ... ?>

[Date:]
    7 July 2002


Class protocol:

defaults
o  defaultAsStringSelector

instance creation
o  on: aString
Creates an instance of the receiver on aString

o  on: aString asStringSelector: aSymbol
Creates an instance of the receiver on aString


Instance protocol:

accessing
o  asStringSelector
Returns the selector used to show objects as Strings on the receiver

o  asStringSelector: aSymbol
Sets the selector used to show objects as Strings on the receiver

o  sttCode
Returns the receiver's Smalltalk Template code

caching
o  cache
Returns the receiver's cached object

o  cache: anObject
Save anObject in the receiver's cache

o  flushIfOlderThanFile: aFile

o  initializeCache
Initialize the receiver's cache

o  isCached
Tell if the receiver is cached or not. In the future,
this will consider the fact that a cached object may
become old after some time, and that means that the
object is NOT cached anymore.

o  isOlderThanFile: aFile

code generation
o  asSmalltalkCode: sttCode model: commancheModel
Returns the equivalent version of the receiver as Smalltalk code

o  asSmalltalkCodeWithModel: aModel
Returns the equivalent version of the receiver as Smalltalk code

o  writeOutputCodeFor: aString on: aStream
Writes on aStream the required Smalltalk code for sending aString as reply

compiling
o  compileFor: aComancheModel
Compiles the receiver's template in aClass and returns aCompiledMethod

evaluating
o  evaluateFor: aComancheModel
Evaluates the receiver within for anObject

initializing
o  initializeOn: aString asStringSelector: aSymbol


Examples:


Try these expressions:

  (STTTemplate on: 'Repeating word...<?stt 10 timesRepeat: [ ?> WORD <?stt ] ?>   end!') evaluateFor: nil.

  (STTTemplate on: 'Counting: 
                  <?stt self to: 10 do: [ :each | ?>
                          [<?stt = each ?>]
                  <?stt ] ?>'
  ) evaluateFor: 1.


obsolete (non xml-compliant):
  (STTTemplate on: 'Repeating word...{% 10 timesRepeat: [ %} WORD {% ] %}   end!') evaluateFor: nil.

  (STTTemplate on: 'Counting: 
                  {% self to: 10 do: [ :each | %}
                          [{%= each %}]
                  {% ] %}'
  ) evaluateFor: 1.



checking documents:
  XML::XMLParser
      processDocumentInFilename:'../../goodies/webServer/data/comancheSTT/test1.stt'
      beforeScanDo:[:p | p validate:false]
  XML::XMLParser
      processDocumentInFilename:'../../goodies/webServer/data/comancheSTT/test4.stt'
      beforeScanDo:[:p | p validate:false]


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 16:12:02 GMT