This site's content was compiled from 1993 to 2006. Beyond that, Google is your friend.
Lyn Headley
An HTML formatting library. The basic idea is that there is a class for each HTML entity, plus a few base classes for behavior and implementation.
The base class of any HTML element is HT_ELEMENT. This has features dealing with attributes (key=value pairs found in basically all elements) and has a feature which generates a tag, from a (deferred) feature tag_text, so e.g. the <title> tag has tag_text title. HT_ELEMENT also declares the feature to_html, which is the main method clients call to get a stringified version of the markup which encodes the object.
Right beneath HT_ELEMENT is HT_CONTAINER, the base class for elements which contain other elements (including the special case of HT_RAW, which is just a way to type strings as HT_ELEMENTs so they can be put into HT_CONTAINERs). This does all the work of inserting and rendering the contained elements. It also introduces the notion of an end tag, which of course container elements require. HT_CONTAINER also inherits from the gobo class DS_ARRAYED_LIST[HT_ELEMENT].
One step below HT_CONTAINER is HT_RAW_WRAPPER, a base class for things like <title> and <b>, which (usually) simply surround some text. for this common case, HT_RAW_WRAPPER provides the creation function make_with(text: STRING).
Once this infrastructure has been set up, the concrete HTML classes become really simple. Here is HT_TITLE, for instance:
class HT_TITLE
inherit
HT_RAW_WRAPPER
redefine tag_text
end
creation
make_with
feature
tag_text: STRING is "title"
end -- class HT_TITLE
Here is how you might use the library:
feature
succeeded is
local
html: HT_HTML
bold: HT_B
br: HT_BR
link: HT_A
do
!!html.make
html.set_title("Referendum: Login Successful")
!!bold.make_with("Thank you. You are now logged in")
html.force_last(bold)
!!bold.make_with("(Assuming your browser supports cookies)")
html.force_last(bold)
!!br.make
html.force_last(br)
!!link.make_with("/cgi-bin/referendum?propose", "Continue")
html.force_last(link)
print(html.to_html)
end -- succeeded