Friday, July 17, 2015

Smalltel

Pharo 5 now fully includes Opal Compiler - the old one will be removed. This allows for many nice extensions.

 For instance Ronie Salgado has a small package called "Smalltel" - the name is an abbreviation for Smalltalk string template language. The package provides a class SmalltelCompiler as a subclass OpalCompiler.

There is also a class SmalltelObject overriding the method #compilerClass to return the new compiler class. With the custom compiler one can provide templates with expressions in Smalltalk, a little bit similar to what Java has with Expression Language (EL):




condition: cond value: value
 ^ ByteString streamContents:
<[Here goes a header:
 ${ cond ifTrue: [ }$
  Conditional value: $( value printString )$
 ${ ]. }$
]>

No comments: