help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] CGI enabled STT


From: Markus Fritsche
Subject: Re: [Help-smalltalk] CGI enabled STT
Date: Sun, 05 Jan 2003 12:46:25 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3a) Gecko/20021212

Bonzini wrote:

Interesting.  I would move the actual code to generate HTML to the instance
side, so that you can specify a custom stream.  Then, the class-side
#doesNotUnderstand: would redirect to a particular instance that writes to
stdout.

I've changed it so that
HTML something: nil!
returns '<something />'
and
(HTML new) stream: stdout; something: nil!
writes "<something />" on stdout.

Regards, Markus


--
http://reauktion.de/archer/
Object subclass: #HTML instanceVariableNames: 'tag params data stream' classVariableNames: '' poolDictionaries: '' category: 'MFCGI-Utilities'! HTML comment: ' I am a simple evaluate and transform class. My usage is not as simple as it should be! Example: HTML a: {''href''->''http://reauktion.de/archer'' . ''Markus Fritsche ''} evaluates to: Markus Fritsche HTML br: '' '! HTML methodsFor: 'proxiing'! process: aMessage | arg inst | tag := aMessage selector allButLast. aMessage arguments first isString ifTrue: [ arg := aMessage arguments ] ifFalse: [ arg := aMessage arguments first ifNil: [ {nil} ]]. arg do: [ :i | (i isKindOf: Association) ifTrue: [ self params add: i ] ifFalse: [ self data add: i ] ]. stream nextPutAll: self asString ! doesNotUnderstand: aMessage ^ self process: aMessage ! ! HTML class methodsFor: 'proxiing'! doesNotUnderstand: aMessage | tstream inst | tstream := WriteStream on: String new. inst := self new. inst stream: tstream. inst process: aMessage. ^ tstream contents ! ! HTML methodsFor: 'conversion'! asString | tstream | tstream := WriteStream on: String new. tstream nextPut: $<; nextPutAll: tag. (self params size > 0) ifTrue: [ self params keysAndValuesDo: [ :k :v | tstream nextPut: $ ; nextPutAll: k; nextPutAll: '="'; nextPutAll: v; nextPut: $" ] ]. (data first isNil) ifFalse: [ tstream nextPut: $>. data do: [ :e | tstream nextPutAll: e asString ]. tstream nextPutAll: '. ] ifTrue: [ tstream nextPutAll: ' />' ]. ^tstream contents ! ! HTML class methodsFor: 'instance-creation'! new ^super new initialize ! ! HTML methodsFor: 'initialize-release'! initialize params := Dictionary new. data := OrderedCollection new ! ! HTML methodsFor: 'accessing'! stream: aStream stream := aStream ! stream ^stream ! tag: aString tag := aString ! tag ^tag ! data: anObject data := anObject ! data ^ data ! params ^params ! params: anObject params := anObject ! !
reply via email to

[Prev in Thread] Current Thread [Next in Thread]