Skip to content

Commit d49f268

Browse files
committed
Modify HTML builder to expose some protected methods
All the formaer virtual abstract protected instance were made public and changed to class methods. This is so that the information they provide is made available to calling code without instantiating a THTMLBuilder derivative object.
1 parent 616a85d commit d49f268

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

Src/UHTMLBuilder.pas

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,19 @@ THTMLBuilder = class abstract (TObject)
7676
BodyTagName = 'body';
7777
PreTagName = 'pre';
7878
SpanTagName = 'span';
79-
strict protected
79+
public
8080
/// <summary>Returns the class used to generate tags for the appropriate
8181
/// type of HTML.</summary>
82-
function TagGenerator: THTMLClass; virtual; abstract;
82+
class function TagGenerator: THTMLClass; virtual; abstract;
8383
/// <summary>Returns any preamble to be written to the HTML before the
8484
/// opening &lt;html&gt; tag.</summary>
85-
function Preamble: string; virtual; abstract;
85+
class function Preamble: string; virtual; abstract;
8686
/// <summary>Returns the attributes of the document's &lt;html&gt; tag.
8787
/// </summary>
88-
function HTMLTagAttrs: IHTMLAttributes; virtual; abstract;
88+
class function HTMLTagAttrs: IHTMLAttributes; virtual; abstract;
8989
/// <summary>Returns any &lt;meta&gt; tags to be included within the
9090
/// document's &lt;head&gt; tag.</summary>
91-
function MetaTags: string; virtual; abstract;
91+
class function MetaTags: string; virtual; abstract;
9292
public
9393
/// <summary>Object constructor. Initialises object with empty body.
9494
/// </summary>
@@ -146,19 +146,19 @@ TXHTMLBuilder = class sealed(THTMLBuilder)
146146
// XML document type
147147
XHTMLDocType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '
148148
+ '"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
149-
strict protected
149+
public
150150
/// <summary>Returns the class used to generate XHTML compliant tags.
151151
/// </summary>
152-
function TagGenerator: THTMLClass; override;
152+
class function TagGenerator: THTMLClass; override;
153153
/// <summary>Returns the XML processing instruction followed by the XHTML
154154
/// doctype.</summary>
155-
function Preamble: string; override;
155+
class function Preamble: string; override;
156156
/// <summary>Returns the attributes required for an XHTML &lt;html&gt; tag.
157157
/// </summary>
158-
function HTMLTagAttrs: IHTMLAttributes; override;
158+
class function HTMLTagAttrs: IHTMLAttributes; override;
159159
/// <summary>Returns a &lt;meta&gt; tag that specifies the text/html
160160
/// content type and UTF-8 encodiing.</summary>
161-
function MetaTags: string; override;
161+
class function MetaTags: string; override;
162162
end;
163163

164164
/// <summary>Class used to create the content of a HTML 5 document.</summary>
@@ -167,18 +167,18 @@ THTML5Builder = class sealed(THTMLBuilder)
167167
const
168168
// HTML 5 document type
169169
HTML5DocType = '<!DOCTYPE HTML>';
170-
strict protected
170+
public
171171
/// <summary>Returns the class used to generate HTML 5 compliant tags.
172172
/// </summary>
173-
function TagGenerator: THTMLClass; override;
173+
class function TagGenerator: THTMLClass; override;
174174
/// <summary>Returns the HTML 5 doctype.</summary>
175-
function Preamble: string; override;
175+
class function Preamble: string; override;
176176
/// <summary>Returns the attributes required for an HTML 5 &lt;html&gt;
177177
/// tag.</summary>
178-
function HTMLTagAttrs: IHTMLAttributes; override;
178+
class function HTMLTagAttrs: IHTMLAttributes; override;
179179
/// <summary>Returns a &lt;meta&gt; tag that specifies that the document
180180
/// uses UTF-8 encoding.</summary>
181-
function MetaTags: string; override;
181+
class function MetaTags: string; override;
182182
end;
183183

184184

@@ -312,7 +312,7 @@ function THTMLBuilder.TitleTag: string;
312312

313313
{ TXHTMLBuilder }
314314

315-
function TXHTMLBuilder.HTMLTagAttrs: IHTMLAttributes;
315+
class function TXHTMLBuilder.HTMLTagAttrs: IHTMLAttributes;
316316
begin
317317
Result := THTMLAttributes.Create(
318318
[THTMLAttribute.Create('xmlns', 'https://www.w3.org/1999/xhtml'),
@@ -321,7 +321,7 @@ function TXHTMLBuilder.HTMLTagAttrs: IHTMLAttributes;
321321
);
322322
end;
323323

324-
function TXHTMLBuilder.MetaTags: string;
324+
class function TXHTMLBuilder.MetaTags: string;
325325
begin
326326
Result := TagGenerator.SimpleTag(
327327
MetaTagName,
@@ -332,24 +332,24 @@ function TXHTMLBuilder.MetaTags: string;
332332
);
333333
end;
334334

335-
function TXHTMLBuilder.Preamble: string;
335+
class function TXHTMLBuilder.Preamble: string;
336336
begin
337337
Result := XMLProcInstruction + EOL + XHTMLDocType;
338338
end;
339339

340-
function TXHTMLBuilder.TagGenerator: THTMLClass;
340+
class function TXHTMLBuilder.TagGenerator: THTMLClass;
341341
begin
342342
Result := TXHTML;
343343
end;
344344

345345
{ THTML5Builder }
346346

347-
function THTML5Builder.HTMLTagAttrs: IHTMLAttributes;
347+
class function THTML5Builder.HTMLTagAttrs: IHTMLAttributes;
348348
begin
349349
Result := THTMLAttributes.Create('lang', 'en');
350350
end;
351351

352-
function THTML5Builder.MetaTags: string;
352+
class function THTML5Builder.MetaTags: string;
353353
begin
354354
// <meta charset="UTF-8">
355355
Result := TagGenerator.SimpleTag(
@@ -358,12 +358,12 @@ function THTML5Builder.MetaTags: string;
358358
);
359359
end;
360360

361-
function THTML5Builder.Preamble: string;
361+
class function THTML5Builder.Preamble: string;
362362
begin
363363
Result := HTML5DocType;
364364
end;
365365

366-
function THTML5Builder.TagGenerator: THTMLClass;
366+
class function THTML5Builder.TagGenerator: THTMLClass;
367367
begin
368368
Result := THTML5;
369369
end;

0 commit comments

Comments
 (0)