19.3Rendering News Items
Finally, we want to render the todo items. Each news item is enclosed within a item
tag. We will display the title and show the due date as part of the description. Also we prepend the string (done)
, if the item has been completed.
ToDoRssFeed>>renderContentOn: rss
self renderChannelOn: rss.
self model items
do: [ :each | self renderItem: each on: rss ]
ToDoRssFeed>>renderItem: aToDoItem on: rss
rss item: [
rss title: aToDoItem title.
rss description: [
aToDoItem done
ifTrue: [ rss text: '(done) ' ].
rss render: aToDoItem due ] ]
Doing so will generate the required XML structure for the item tag.
<item> <title>Smalltalk</title> <description>(done) 5 March 2008</description> </item>
At the minimum, a title or a description must be present. All the other sub-elements are optional.