'From Squeak3.2gamma of 17 March 2002 [latest update: #4857] on 7 July 2002 at 3:41:07 am'! "Change Set: SSP Date: 7 July 2002 Author: Federico Gregorio Stilman SSP (Smalltalk Server Pages) support. Enables embedding Smalltalk code in HTML and other documents too."! Object subclass: #SSPTemplate instanceVariableNames: 'sspCode ' classVariableNames: '' poolDictionaries: '' category: 'SSP-Core'! !SSPTemplate methodsFor: 'private' stamp: 'FGS 7/7/2002 03:35'! asSmalltalkCode "Returns the equivalent version of the receiver as Smalltalk code" | sspOpenIndex sspCloseIndex lastIndex sspCodeIndex stream | stream _ String new writeStream. stream nextPutAll: '| out | out _ String new writeStream.'; cr. lastIndex _ 1. [ (sspOpenIndex _ self sspCode indexOfSubCollection: '<%' startingAt: lastIndex) > 0] whileTrue: [ stream nextPutAll: 'out nextPutAll: '''; nextPutAll: (self sspCode copyFrom: lastIndex to: sspOpenIndex - 1); nextPutAll: '''.'; cr. sspCloseIndex _ self sspCode indexOfSubCollection: '%>' startingAt: sspOpenIndex ifAbsent: [ ^ self error: 'Missing closing tag' ]. sspCodeIndex _ sspOpenIndex + 2. (sspCode at: sspOpenIndex + 2) = $= ifTrue: [ stream nextPutAll: 'out nextPutAll: ('. sspCodeIndex _ sspCodeIndex + 1. ]. stream nextPutAll: (sspCode copyFrom: sspCodeIndex to: sspCloseIndex - 1). (sspCode at: sspOpenIndex + 2) = $= ifTrue: [ stream nextPutAll: ') asString.' ]. stream cr. lastIndex _ sspCloseIndex + 2. ]. stream nextPutAll: 'out nextPutAll: '''; nextPutAll: (self sspCode copyFrom: lastIndex to: sspCode size); nextPutAll: '''.'; cr; nextPutAll: '^ out contents'; cr. ^ stream contents ! ! !SSPTemplate methodsFor: 'private' stamp: 'FGS 7/7/2002 03:30'! writeOutputCodeFor: aString on: aStream aStream nextPutAll: 'out nextPutAll: '''; nextPutAll: aString; nextPutAll: '''.'; cr.! ! !SSPTemplate methodsFor: 'evaluating' stamp: 'FGS 7/7/2002 02:37'! evaluateOn: anObject "Evaluates the receiver within the context of anObject" ^ Compiler evaluate: self asSmalltalkCode for: anObject logged: false. ! ! !SSPTemplate methodsFor: 'accessing' stamp: 'FGS 7/7/2002 02:24'! sspCode ^ sspCode! ! !SSPTemplate methodsFor: 'initializing' stamp: 'FGS 7/7/2002 02:24'! initializeOn: aString sspCode _ aString! ! !SSPTemplate class methodsFor: 'unit testing' stamp: 'FGS 7/7/2002 02:50'! test | sspTest | sspTest _ '
<%= each %> | <%= each * 2 %> |
This paragraph was manually send out
'' ]. %> '. ^ (SSPTemplate on: sspTest) evaluateOn: 1.! ! !SSPTemplate class methodsFor: 'instance creation' stamp: 'FGS 7/6/2002 17:25'! on: aString ^ super new initializeOn: aString.! !