Tuesday, December 4, 2012

Aida/Web markup in Smalltalk (again)


I hate reinventing the wheel ... as the man said, you are likely to get a flat. It should be a Unicode character: the wheel with one part of circumference 'flat'.

Here is some AidaWeb Smalltalk code:
streamHtmlTo: aStream for: aRequest on: aSession
| tag |
self prepareToHtmlStreamingOn: aSession.
type = #paragraph ifTrue: [tag := 'p'].
type = #break ifTrue: [tag := 'br'].
type = #ruler ifTrue: [tag := 'hr'].
aStream nextPutAll: self ident, '<', tag.
self streamAttributesTo: aStream for: aSession.
aStream nextPutAll: self tagClosing, self eol.
But Curl markup uses "hrule" and not "hr" and a '{' and not a '<'.

Markup neutrality is not so hard to achieve - without massive duplication of classes - especially in a language such as Pharo Smalltalk with Traits as mix-ins.



No comments: