[Seaside] templating engines

keith keith_hodges at yahoo.co.uk
Wed Oct 14 18:56:35 UTC 2009


On 14 Oct 2009, at 17:41, Sean Allen wrote:

> What did seaside use for templates before it switched to  
> programmatic html generation?
>
> I'm trying to find template engines that we could use in our  
> application for areas where backend users need to be able insert small
> amount of text into the programmatically created html. the text that  
> the insert needs some basic templating ability and i'd prefer
> to not roll our own.
>
> Pointers to any smalltalk templating solutions would also be  
> appreciated.

I put my templates into pier pages for the administrators to edit, and  
use this to fill in the template.

expand: string mergeUsing: dataSource

	| split  |

	string ifNil: [ ^'' ].
   	dataSource ifNil: [ ^ string ].
		
	split := string splitOn: '%'.
	
	split size < 3 ifTrue: [ ^ string ].
	
	split withIndexDo: [ :each :n |
	 	n even ifTrue: [
			| result |
			result := (each splitOn: ':')
				inject: dataSource
				into: [ :data :accessor | [ data perform: accessor asSymbol ]  
ifError:  [ '%', each, '%' ] ].
			
			split at: n put: result.
		]
	].

	^ (split joinUsing: '')

best regards

Keith
  


More information about the seaside mailing list