/ Assembly List / LJCNetCommon / HTMLBuilder

Namespace - LJCNetCommon


Syntax

C#
public class HTMLBuilder

Provides methods for creating HTML text.

Remarks

The HTMLBuilder class is designed for creating HTML text. It is similar in principle to the StringBuilder class which is designed for creating strings.

The HTMLBuilder class - like the StringBuilder class - stores the text internally. The text is retrieved with the ToString() method.

Add Text Methods
The "Add" methods are similar to StringBuilder methods:
AddLine() - StringBuilder.AppendLine()
AddText() - StringBuilder.Append()
"Add" methods add text to the builder unmodified except for AddLine() which appends a newline.

Append Text Methods
Line(), Text()
"Append" methods add the potentially indented and wrapped text to the builder.
The Text() method creates the added text without an ending newline This behavior is done for consistency and it allows the developer to append to the existing text.
"Append" methods start the text with a newline if the builder already has text, param allowNewLine = true and builder text does not end with a newline.
The Line() and Text() methods should have the addIndent property set to false if it applies text retrieved with a "Get" method as the "Get" method has already applied the indent.

The AddIndent() method manually controls the current indent count. The indent string length is calculated with the properties (IndentCount * IndentCharCount) and can be retrieved with the IndentLength property.

Get Text Methods
GetLine(), GetText()
All "Get" methods create and return the potentialy indented and wrapped text but do not add it to the builder.

Append Element Methods
Begin(), Create(), End()
These methods append element tags and content. Begin() automatically increments the IndentCount by 1. Create() also increments the IndentCount by 1 if the isEmpty parameter is false and the close parameter is false. End() automatically decrements the IndentCount by 1 if the IndentCount is currently greater than zero.
The "Append" element methods create the added text without an ending newline. This behavior is done for consistency and it allows the developer to append to the existing text.
"Append" methods start the text with a newline if the builder already has text, param allowNewLine = true and builder text does not end with a newline.

Other Append Element Methods
Link(), Meta(), Metas(), Script()
These methods also append elements but do not change the IndentCount value.
The "Append" element methods create the added text without an ending newline. This behavior is done for consistency and it allows the developer to append to the existing text.
"Append" methods start the text with a newline if the builder already has text, param allowNewLine = true and builder text does not end with a newline.

Get Element Methods
GetBegin(), GetCreate(), GetEnd(), GetLink(), GetMeta(), GetMetas() , GetScript()
All "Get" methods create and return the potentialy indented and wrapped text but do not add it to the builder.

Constructor
#ctor Initializes an object instance.

Data
ToString Implements the ToString() method.

Methods
AddIndent Changes the IndentCount by the supplied value.

Append Text
AddLine Adds a text line without modification.
AddText Adds text without modification.
Line Adds a modified text line to the builder.
Text Adds modified text to the builder.

Get Text
GetAttribs Gets the attributes text.
GetIndented Gets a new line with indent.
GetIndentString Returns the current indent string.
GetLine Gets a modified text line.
GetText Gets potentially indented and wrapped text.
GetWrapped Appends added text and new wrapped line if combined line > LineLimit.

Append Element
Begin Appends the element begin tag.
Create Appends an element.
End Appends the element end tag.
Link Appends a <link> element for a style sheet.
Meta Appends a <meta> element.
Metas Appends common <meta&rt; elements.
Script Appends a <script> element.

Get Element
AddChildIndent Adds the new (child) indents.
GetBegin Gets the element begin tag.
GetBeginSelector Gets beginning of style selector.
GetCreate Gets an element.
GetEnd Gets the element end tag.
GetLink Gets the link element for a style sheet.
GetMeta Gets a meta element.
GetMetas Gets common meta elements.
GetScript Gets a <script> element.

Append HTML
HTMLBegin Creates the HTML beginning up to and including head;.

Get HTML
GetHTMLBegin Gets the HTML beginning up to and including <head>.
GetHTMLEnd Gets the HTML end <body> and <html>.
GetHTMLHead Missing Summary

Get Attributes
Attribs Gets common element attributes.
StartAttribs Creates the HTML start attributes.
TableAttribs Gets common table attributes.

Other Public Methods
EndsWithNewLine Indicates if the builder text ends with a newline.
StartWithNewLine Allow text to start with a newline.
37 Methods

Other Private Methods
1 Methods

Properties
Builder The internal StringBuilder class.
HasText Indicates if the builder has text.
IndentCharCount Gets or sets the indent character count.
IndentCount Gets the indent count.
IndentLength Gets the current indent length.
LineLength Gets the current length.
LineLimit Gets or sets the character limit.
NewIndentCount Gets or sets the new indent count.
WrapEnabled Indicates if line wrapping is enabled.

Fields
DebugText Missing Summary

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.