rigz.htmltools: Globals Functions Types Modinfo Source  

HTML Tools module for building HTML documents

This is a simple module for aiding in the creation of HTML documents. Note: requires BaH.LibXML.

Globals Summary

DXHTMLStrict , DXHTMLTransitional , TAGS

Functions Summary

CreateHTMLBlock Create a new tHTMLTag.
CreateHTMLDoc Create a new tHTMLDoc.
LoadHTMLDoc Load an HTML Document from a file.
SaveHTMLDoc Save a tHTMLDoc to a file.

Types Summary

tDoctype type for storing different doctypes for WW3 Doctypes.
tHTMLConstructor Type for storing HTML tags and tHTMLTag constructors.
tHTMLDoc An html doc type.
tHTMLTag Type for storing Blocks of HTML.
tProperty Type for storing HTML properties/attributes.
tStyle tStyle type for storing CSS.
tStyleProperty Type for storing Style properties.

Globals

Global DXHTMLStrict:tdoctype
DescriptionGlobal tDoctype storing the doctype for an XHTML Strict HTML document.

Global DXHTMLTransitional:tDoctype
DescriptionGlobal tDoctype storing the doctype for an XHTML Transitional HTML document.

Global TAGS:tHTMLConstructor
DescriptionGlobal tHTMLConstructor type for accessing preset HTML tags and constructors for tHTMLTag.

Functions

Function CreateHTMLBlock:tHTMLTag(name:String, container:Int = True, plaintext:Int = False)
ReturnsNew tHTMLTag.
DescriptionCreate a new tHTMLTag.
InformationPass the name of the tag, whehter it can contain children, and specify if it should or shouldn't be plain text (no tag). For best results, use tHTMLConstructors for an easier way to create html blocks.

Function CreateHTMLDoc:tHTMLDoc(doctype:tDoctype)
DescriptionCreate a new tHTMLDoc.
InformationPass the doctype, you can use the follwing consts for this: DXHTMLTransitional, DXHTMLStrict.

Function LoadHTMLDoc:tHTMLDoc(url:Object)
DescriptionLoad an HTML Document from a file.

Function SaveHTMLDoc(url:String, htmldoc:tHTMLDoc)
DescriptionSave a tHTMLDoc to a file.

Types

Type tDoctype
Descriptiontype for storing different doctypes for WW3 Doctypes.
Methods Summary
ToString convert this doctype into a string.
Functions Summary
Create Create a new Doctype.
Method ToString:String()
Descriptionconvert this doctype into a string.
Function Create:tDoctype(externalid:String, systemid:String, name:String)
Returnsa new tDoctype.
DescriptionCreate a new Doctype.

Type tHTMLConstructor
DescriptionType for storing HTML tags and tHTMLTag constructors.
InformationThis type can be accessed through the global Tags and provides a convienient way of constructing tTags.
Methods Summary
A Create and return the HTML tag: a.
B Create and return the HTML tag: b.
BIG Create and return the HTML tag: big.
BODY Create and return the HTML tag: body.
BR Create and return the HTML tag: br.
DIV Create and return the HTML tag: div.
EM Create and return the HTML tag: em.
H1 Create and return the HTML tag: h1.
H2 Create and return the HTML tag: h2.
H3 Create and return the HTML tag: h3.
H4 Create and return the HTML tag: h4.
H5 Create and return the HTML tag: h5.
H6 Create and return the HTML tag: h6.
HEAD Create and return the HTML tag: head.
HR Create and return the HTML tag: hr.
HTML Create and return the HTML tag: html.
I Create and return the HTML tag: i.
IMG Create and return the HTML tag: img.
IsContainer Find out whether an HTML tag can contain other tags.
IsPlainText Find out if a node name is plaintext.
LI Create and return the HTML tag: li.
META Create and return the HTML tag: meta.
NeedsNewLine See if a particular tag requires a new line when being formatted into a string.
P Create and return the HTML tag: p.
PlainText Create and return a tHTMLTag that is just plain text (no html tag)
SMALL Create and return the HTML tag: small.
SPAN Create and return the HTML tag: span.
STRONG Create and return the HTML tag: strong.
STYLE Create and return the HTML tag: style.
SUB Create and return the HTML tag: sub.
SUP Create and return the HTML tag: sup.
TABLE Create and return the HTML tag: table.
TD Create and return the HTML tag: td.
TH Create and return the HTML tag: th.
TITLE Create and return the HTML tag: title.
TR Create and return the HTML tag: tr.
TT Create and return the HTML tag: tt.
UL Create and return the HTML tag: ul.
Method A:tHTMLTag(href:String = "", title:String = "")
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: a.
Method B:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: b.
Method BIG:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: big.
Method BODY:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: body.
Method BR:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: br.
Method DIV:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: div.
Method EM:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: em.
Method H1:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: h1.
Method H2:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: h2.
Method H3:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: h3.
Method H4:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: h4.
Method H5:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: h5.
Method H6:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: h6.
Method HR:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: hr.
Method HTML:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: html.
Method I:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: i.
Method IMG:tHTMLTag(src:String = "", alt:String = "")
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: img.
Method IsContainer:Int(tag:String)
DescriptionFind out whether an HTML tag can contain other tags.
Method IsPlainText:Int(name:String)
ReturnsTrue or False.
DescriptionFind out if a node name is plaintext.
Method LI:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: li.
Method META:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: meta.
Method NeedsNewLine:Int(tag:String)
DescriptionSee if a particular tag requires a new line when being formatted into a string.
Method P:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: p.
Method PlainText:tHTMLTag(text:String = "")
ReturnsNew tHTMLTag.
DescriptionCreate and return a tHTMLTag that is just plain text (no html tag)
Method SMALL:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: small.
Method SPAN:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: span.
Method STRONG:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: strong.
Method STYLE:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: style.
Method SUB:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: sub.
Method SUP:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: sup.
Method TABLE:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: table.
Method TD:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: td.
Method TH:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: th.
Method TITLE:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: title.
Method TR:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: tr.
Method TT:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: tt.
Method UL:tHTMLTag()
ReturnsNew tHTMLTag.
DescriptionCreate and return the HTML tag: ul.

Type tHTMLDoc
DescriptionAn html doc type.
InformationThis type can be used to store an HTML document, specifying a doctype and containing the root html tag.
Example
Import rigz.htmltools

'Create an HTML document
Local htmldoc:tHTMLDoc = CreateHTMLDoc(DXHTMLStrict)

'Create some HTML Tags using Tags object to construct them more easily.
Local head:tHTMLTag = Tags.HEAD()
Local title:tHTMLTag = Tags.TITLE()
'Use addchild to create a structured HTML document
title.AddChild(Tags.PlainText("A Simple HTML Document"))
head.AddChild(title)
Local body:tHTMLTag = Tags.BODY()
Local div:tHTMLTag = Tags.DIV()
'You can also use AddStyle to add inline CSS to HTML Tags
div.AddStyle("text-align", "center")
div.AddStyle("font-family", "Arial, Verdana, Times New Roman")
Local p:tHTMLTag = Tags.P()
p.AddChild(Tags.PlainText("This is a very simple HTML document"))
div.AddChild(p)
body.AddChild(div)

htmldoc.AddChild(head)
htmldoc.AddChild(body)

Print htmldoc.ToString()
Methods Summary
AddChild Add a child tHTMLTag to the root html tag of this HTML doc.
GetRootHTML Get the root html tag of the document.
SetRootHTML set the root html tag of the document.
ToString Convert the HTML document to a string.
Functions Summary
Create Create a new tHTMLDoc.
Method AddChild(block:tHTMLTag)
DescriptionAdd a child tHTMLTag to the root html tag of this HTML doc.
Method GetRootHTML:tHTMLTag()
ReturnstHTMLTag.
DescriptionGet the root html tag of the document.
Method SetRootHTML(htmlblock:tHTMLTag)
Descriptionset the root html tag of the document.
Informationthis should be an "HTML" tag.
Method ToString:String()
ReturnsFormatted string.
DescriptionConvert the HTML document to a string.
InformationThe string this returns can be loaded into an HTML viewer.
Function Create:tHTMLDoc(doctype:tDoctype)
DescriptionCreate a new tHTMLDoc.
InformationPass the doctype, you can use the follwing consts for this: DOCTYPE_XHTML1_TRANSITIONAL, DOCTYPE_XHTML1_STRICT.

Type tHTMLTag
DescriptionType for storing Blocks of HTML.
Informationthis type provides the means to store HTML data, with each block being capable of containing child blocks to achieve a proper HTML document structure.
Methods Summary
AddChild Add a child tHTMLTag.
AddProperty Add a new property to the html block.
AddStyle Add an inline style to the html block.
AppendText Append text to a plain text html block.
GetNewline Get the value of newline.
GetStyle Set the style of this html block.
GetText Get the text of a plain text html block.
SetNewline Set the value of newline.
SetStyle Set the style of this html block.
SetText Set the text of a plain text html block.
ToString Convert the tHTMLTag into a string.
Functions Summary
Create Create a new tHTMLTag.
Method AddChild(HTMLBlock:tHTMLTag)
DescriptionAdd a child tHTMLTag.
InformationThis is essential if want to add nested html blocks.
Method AddProperty(name:String, value:String)
DescriptionAdd a new property to the html block.
InformationAdds a new property yo the type for example "src" would be a property of an image tag.
Method AddStyle(name:String, value:String)
DescriptionAdd an inline style to the html block.
InformationAdds new style property to the html block, passing the name and the value. eg. style="float: right" where float would be the name and left the value.
Method AppendText(value:String)
DescriptionAppend text to a plain text html block.
InformationIf an html block is plain text only, then you can use this to append some text.
Method GetNewline(value:Int)
DescriptionGet the value of newline.
InformationIf Newline is true then this HTML tag will start on a new line when parsed into a string. By default newline is true.
Method GetStyle:tStyle()
DescriptionSet the style of this html block.
Method GetText:String()
DescriptionGet the text of a plain text html block.
InformationIf an html block is plain text only, then you can use this to retrieve the text.
Method SetNewline(value:Int)
DescriptionSet the value of newline.
InformationSet newline to false if you don't want this HTML tag to start on a new line when parsed into a string. By default newline is true.
Method SetStyle(value:tStyle)
DescriptionSet the style of this html block.
Informationthe style will be applied inline to the HTML block.
Method SetText(value:String)
DescriptionSet the text of a plain text html block.
InformationIf an html block is plain text only, then you can use this to set the text.
Method ToString:String()
ReturnsFormatted string.
DescriptionConvert the tHTMLTag into a string.
Function Create:tHTMLTag(name:String, container:Int = True, plaintext:Int = False)
ReturnsNew tHTMLTag.
DescriptionCreate a new tHTMLTag.
InformationPass the name of the tag, whehter it can contain children, and specify if it should or shouldn't be plain text (no tag). For best results, use tHTMLConstructors for an easier way to create html blocks.

Type tProperty
DescriptionType for storing HTML properties/attributes.
InformationAn HTML property is for example, on an img tag, you could have the property src and alt.
Methods Summary
GetValue Get the value of the property.
SetValue Set the value of the property.
ToString Convert the tProperty to a string.
Functions Summary
Create Create a new tProperty.
Method GetValue:String()
ReturnsString containing the value.
DescriptionGet the value of the property.
Method SetValue(v:String)
DescriptionSet the value of the property.
Method ToString:String()
ReturnsFormated string.
DescriptionConvert the tProperty to a string.
Function Create:tProperty(name:String, value:String)
ReturnsNew tProperty.
DescriptionCreate a new tProperty.

Type tStyle
DescriptiontStyle type for storing CSS.
InformationThis type is used for storing CSS properties.
Methods Summary
AddProperty Add a new property to the style, or update an existing one.
FindStyleProperty Find a style property.
StyleExists Find out if a property exists.
ToString Convert the tStyle to a string.
UpdateProperty Update an existing style property.
Functions Summary
Create Create new tStyle.
Method AddProperty(name:String, value:String)
DescriptionAdd a new property to the style, or update an existing one.
InformationAdds a style property, such as text-align, width, background-color etc., pass the name and the value. If the property already exists then it is updated rather then a new one added.
Method FindStyleProperty:tStyleProperty(name:String)
ReturnsThe tStyleProperty if found, otherwise null is returned.
DescriptionFind a style property.
Method StyleExists:Int(name:String)
DescriptionFind out if a property exists.
Method ToString:String()
ReturnsFormatted string.
DescriptionConvert the tStyle to a string.
Method UpdateProperty(name:String, value:String)
DescriptionUpdate an existing style property.
InformationIf the property is not found then nothing happens.
Function Create:tStyle(name:String, inline:Int = True)
ReturnsNew tStyle.
DescriptionCreate new tStyle.
InformationPass the name of the style, for example "#content" and true or false as to whether the style is inline, ie., should appear inline with an HTML tag.

Type tStyleProperty Extends tProperty
DescriptionType for storing Style properties.
Methods Summary
ToString Convert the tStyleProperty to a string.
Functions Summary
Create Create a new tStyleProperty.
Method ToString:String()
ReturnsFormatted string.
DescriptionConvert the tStyleProperty to a string.
Function Create:tStyleProperty(name:String, value:String)
ReturnsNew tStyleProperty.
DescriptionCreate a new tStyleProperty.

Module Information

Version1.0
LicenseMIT
Copyright2010 Peter J Rigby
Historyv1.0 Initial Version