forked from phalcon/cphalcon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTag.zep
1252 lines (1037 loc) · 31.7 KB
/
Tag.zep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <team@phalcon.io>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/
namespace Phalcon;
use Phalcon\Di\DiInterface;
use Phalcon\Escaper\EscaperInterface;
use Phalcon\Tag\Select;
use Phalcon\Tag\Exception;
use Phalcon\Url\UrlInterface;
/**
* Phalcon\Tag is designed to simplify building of HTML tags.
* It provides a set of helpers to generate HTML in a dynamic way.
* This component is a class that you can extend to add more helpers.
*/
class Tag
{
const HTML32 = 1;
const HTML401_STRICT = 2;
const HTML401_TRANSITIONAL = 3;
const HTML401_FRAMESET = 4;
const HTML5 = 5;
const XHTML10_STRICT = 6;
const XHTML10_TRANSITIONAL = 7;
const XHTML10_FRAMESET = 8;
const XHTML11 = 9;
const XHTML20 = 10;
const XHTML5 = 11;
protected static autoEscape = true;
/**
* DI Container
*/
protected static container;
/**
* Pre-assigned values for components
*/
protected static displayValues;
protected static documentAppendTitle = null;
protected static documentPrependTitle = null;
/**
* HTML document title
*/
protected static documentTitle = null;
protected static documentTitleSeparator = null;
protected static documentType = 11;
protected static escaperService = null;
protected static urlService = null;
/**
* Appends a text to current document title
*/
public static function appendTitle(var title) -> void
{
if self::documentAppendTitle === null {
let self::documentAppendTitle = [];
}
if typeof title == "array" {
let self::documentAppendTitle = title ;
} else {
let self::documentAppendTitle[] = title ;
}
}
/**
* Builds a HTML input[type="check"] tag
*/
public static function checkField(var parameters) -> string
{
return self::inputFieldChecked("checkbox", parameters);
}
/**
* Builds a HTML input[type="color"] tag
*/
public static function colorField(var parameters) -> string
{
return self::inputField("color", parameters);
}
/**
* Builds a HTML input[type="date"] tag
*/
public static function dateField(var parameters) -> string
{
return self::inputField("date", parameters);
}
/**
* Builds a HTML input[type="datetime"] tag
*/
public static function dateTimeField(var parameters) -> string
{
return self::inputField("datetime", parameters);
}
/**
* Builds a HTML input[type="datetime-local"] tag
*/
public static function dateTimeLocalField(var parameters) -> string
{
return self::inputField("datetime-local", parameters);
}
/**
* Alias of Phalcon\Tag::setDefault()
*/
public static function displayTo(string! id, value) -> void
{
self::setDefault(id, value);
}
/**
* Builds a HTML input[type="email"] tag
*/
public static function emailField(var parameters) -> string
{
return self::inputField("email", parameters);
}
/**
* Builds a HTML close FORM tag
*/
public static function endForm() -> string
{
return "</form>";
}
/**
* Builds a HTML input[type="file"] tag
*/
public static function fileField(var parameters) -> string
{
return self::inputField("file", parameters);
}
/**
* Builds a HTML FORM tag
*/
public static function form(var parameters) -> string
{
var params, paramsAction, action, code;
if typeof parameters != "array" {
let params = [parameters];
} else {
let params = parameters;
}
if !fetch paramsAction, params[0] {
fetch paramsAction, params["action"];
}
/**
* By default the method is POST
*/
if !isset params["method"] {
let params["method"] = "post";
}
let action = null;
if !empty paramsAction {
let action = self::getUrlService()->get(paramsAction);
}
/**
* Check for extra parameters
*/
if fetch parameters, params["parameters"] {
let action .= "?" . parameters;
}
if !empty action {
let params["action"] = action;
}
let code = self::renderAttributes("<form", params),
code .= ">";
return code;
}
/**
* Converts texts into URL-friendly titles
*/
public static function friendlyTitle(
string text,
string separator = "-",
bool lowercase = true,
var replace = null
) -> string
{
var friendly, locale, search;
if extension_loaded("iconv") {
/**
* Save the old locale and set the new locale to UTF-8
*/
let locale = setlocale(LC_ALL, "en_US.UTF-8"),
text = iconv("UTF-8", "ASCII//TRANSLIT", text);
}
if replace {
if unlikely (typeof replace != "array" && typeof replace != "string") {
throw new Exception(
"Parameter replace must be an array or a string"
);
}
if typeof replace == "array" {
for search in replace {
let text = str_replace(search, " ", text);
}
} else {
let text = str_replace(replace, " ", text);
}
}
let friendly = preg_replace(
"/[^a-zA-Z0-9\\/_|+ -]/",
"",
text
);
if lowercase {
let friendly = strtolower(friendly);
}
let friendly = preg_replace("/[\\/_|+ -]+/", separator, friendly),
friendly = trim(friendly, separator);
if extension_loaded("iconv") {
/**
* Revert back to the old locale
*/
setlocale(LC_ALL, locale);
}
return friendly;
}
/**
* Get the document type declaration of content
*/
public static function getDocType() -> string
{
switch self::documentType
{
case 1: return "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">" . PHP_EOL;
/* no break */
case 2: return "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"" . PHP_EOL . "\t\"http://www.w3.org/TR/html4/strict.dtd\">" . PHP_EOL;
/* no break */
case 3: return "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"" . PHP_EOL . "\t\"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
/* no break */
case 4: return "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"" . PHP_EOL . "\t\"http://www.w3.org/TR/html4/frameset.dtd\">" . PHP_EOL;
/* no break */
case 6: return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" . PHP_EOL . "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">" . PHP_EOL;
/* no break */
case 7: return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" . PHP_EOL."\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" . PHP_EOL;
/* no break */
case 8: return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"" . PHP_EOL . "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">" . PHP_EOL;
/* no break */
case 9: return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"" . PHP_EOL . "\t\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">" . PHP_EOL;
/* no break */
case 10: return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 2.0//EN\"" . PHP_EOL . "\t\"http://www.w3.org/MarkUp/DTD/xhtml2.dtd\">" . PHP_EOL;
/* no break */
case 5:
case 11: return "<!DOCTYPE html>" . PHP_EOL;
/* no break */
}
return "";
}
/**
* Obtains the 'escaper' service if required
*/
public static function getEscaper(array! params) -> <EscaperInterface> | null
{
var autoescape;
if !fetch autoescape, params["escape"] {
let autoescape = self::autoEscape;
}
if !autoescape {
return null;
}
return self::getEscaperService();
}
/**
* Internally gets the request dispatcher
*/
public static function getDI() -> <DiInterface>
{
var di;
let di = self::container;
if typeof di != "object" {
let di = Di::getDefault();
}
return di;
}
/**
* Returns an Escaper service from the default DI
*/
public static function getEscaperService() -> <EscaperInterface>
{
var escaper, container;
let escaper = self::escaperService;
if typeof escaper != "object" {
let container = self::getDI();
if unlikely typeof container != "object" {
throw new Exception(
Exception::containerServiceNotFound("the 'escaper' service")
);
}
let escaper = <EscaperInterface> container->getShared("escaper"),
self::escaperService = escaper;
}
return escaper;
}
/**
* Gets the current document title. The title will be automatically escaped.
*/
public static function getTitle(bool prepend = true, bool append = true) -> string
{
var items, output, title, documentTitle, documentAppendTitle,
documentPrependTitle, documentTitleSeparator, escaper;
let escaper = <EscaperInterface> self::getEscaper(["escape": true]);
let items = [];
let output = "";
let documentTitle = escaper->escapeHtml(self::documentTitle);
let documentTitleSeparator = escaper->escapeHtml(
self::documentTitleSeparator
);
if prepend {
if self::documentPrependTitle === null {
let self::documentPrependTitle = [];
}
let documentPrependTitle = self::documentPrependTitle;
if !empty documentPrependTitle {
var tmp = array_reverse(documentPrependTitle);
for title in tmp {
let items[] = escaper->escapeHtml(title);
}
}
}
if !empty documentTitle {
let items[] = documentTitle;
}
if append {
if self::documentAppendTitle === null {
let self::documentAppendTitle = [];
}
let documentAppendTitle = self::documentAppendTitle;
if !empty documentAppendTitle {
for title in documentAppendTitle {
let items[] = escaper->escapeHtml(title);
}
}
}
if empty documentTitleSeparator {
let documentTitleSeparator = "";
}
if !empty items {
let output = implode(documentTitleSeparator, items);
}
return output;
}
/**
* Gets the current document title separator
*/
public static function getTitleSeparator() -> string
{
return self::documentTitleSeparator;
}
/**
* Returns a URL service from the default DI
*/
public static function getUrlService() -> <UrlInterface>
{
var url, container;
let url = self::urlService;
if typeof url != "object" {
let container = self::getDI();
if unlikely typeof container != "object" {
throw new Exception(
Exception::containerServiceNotFound("the 'url' service")
);
}
let url = <UrlInterface> container->getShared("url"),
self::urlService = url;
}
return url;
}
/**
* Every helper calls this function to check whether a component has a
* predefined value using Phalcon\Tag::setDefault() or value from $_POST
*/
public static function getValue(var name, array params = [])
{
var value;
if !fetch value, params["value"] {
/**
* Check if there is a predefined value for it
*/
if !fetch value, self::displayValues[name] {
/**
* Check if there is a post value for the item
*/
if !fetch value, _POST[name] {
return null;
}
}
}
return value;
}
/**
* Check if a helper has a default value set using Phalcon\Tag::setDefault()
* or value from $_POST
*/
public static function hasValue(var name) -> bool
{
/**
* Check if there is a predefined or a POST value for it
*/
return isset self::displayValues[name] || isset _POST[name];
}
/**
* Builds a HTML input[type="hidden"] tag
*/
public static function hiddenField(var parameters) -> string
{
return self::inputField("hidden", parameters);
}
/**
* Builds HTML IMG tags
*/
public static function image(var parameters = null, bool local = true) -> string
{
var params, code, src;
if typeof parameters != "array" {
let params = [parameters];
} else {
let params = parameters;
if isset params[1] {
let local = (bool) params[1];
}
}
if !isset params["src"] {
if fetch src, params[0] {
let params["src"] = src;
} else {
let params["src"] = "";
}
}
/**
* Use the "url" service if the URI is local
*/
if local {
let params["src"] = self::getUrlService()->getStatic(params["src"]);
}
let code = self::renderAttributes("<img", params);
/**
* Check if Doctype is XHTML
*/
if self::documentType > self::HTML5 {
let code .= " />";
} else {
let code .= ">";
}
return code;
}
/**
* Builds a HTML input[type="image"] tag
*/
public static function imageInput(var parameters) -> string
{
return self::inputField("image", parameters, true);
}
/**
* Builds a SCRIPT[type="javascript"] tag
*/
public static function javascriptInclude(var parameters = null, bool local = true) -> string
{
var params, code;
if typeof parameters != "array" {
let params = [parameters, local];
} else {
let params = parameters;
}
if isset params[1] {
let local = (bool) params[1];
} else {
if isset params["local"] {
let local = (bool) params["local"];
unset params["local"];
}
}
if !isset params["type"] && self::documentType < self::HTML5 {
let params["type"] = "text/javascript";
}
if !isset params["src"] {
if isset params[0] {
let params["src"] = params[0];
} else {
let params["src"] = "";
}
}
/**
* URLs are generated through the "url" service
*/
if local {
let params["src"] = self::getUrlService()->getStatic(params["src"]);
}
let code = self::renderAttributes("<script", params),
code .= "></script>" . PHP_EOL;
return code;
}
/**
* Builds a HTML A tag using framework conventions
*/
public static function linkTo(parameters, text = null, local = true) -> string
{
var params, action, query, url, code;
if typeof parameters != "array" {
let params = [parameters, text, local];
} else {
let params = parameters;
}
if !fetch action, params[0] {
if !fetch action, params["action"] {
let action = "";
} else {
unset params["action"];
}
}
if !fetch text, params[1] {
if !fetch text, params["text"] {
let text = "";
} else {
unset params["text"];
}
}
if !fetch local, params[2] {
if !fetch local, params["local"] {
let local = true;
} else {
unset params["local"];
}
}
if fetch query, params["query"] {
unset params["query"];
} else {
let query = null;
}
let url = self::getUrlService(),
params["href"] = url->get(action, query, local),
code = self::renderAttributes("<a", params),
code .= ">" . text . "</a>";
return code;
}
/**
* Builds a HTML input[type="month"] tag
*/
public static function monthField(var parameters) -> string
{
return self::inputField("month", parameters);
}
/**
* Builds a HTML input[type="number"] tag
*/
public static function numericField(var parameters) -> string
{
return self::inputField("number", parameters);
}
/**
* Builds a HTML input[type="password"] tag
*/
public static function passwordField(var parameters) -> string
{
return self::inputField("password", parameters);
}
/**
* Prepends a text to current document title
*/
public static function prependTitle(var title) -> void
{
if self::documentPrependTitle === null {
let self::documentPrependTitle = [];
}
if typeof title == "array" {
let self::documentPrependTitle = title ;
} else {
let self::documentPrependTitle[] = title ;
}
}
/**
* Builds a HTML input[type="radio"] tag
*/
public static function radioField(var parameters) -> string
{
return self::inputFieldChecked("radio", parameters);
}
/**
* Builds a HTML input[type="range"] tag
*/
public static function rangeField(var parameters) -> string
{
return self::inputField("range", parameters);
}
/**
* Renders parameters keeping order in their HTML attributes
*/
public static function renderAttributes(string! code, array! attributes) -> string
{
var order, escaper, attrs, attribute, value, escaped, key, newCode;
let order = [
"rel" : null,
"type" : null,
"for" : null,
"src" : null,
"href" : null,
"action" : null,
"id" : null,
"name" : null,
"value" : null,
"class" : null
];
let attrs = [];
for key, value in order {
if fetch attribute, attributes[key] {
let attrs[key] = attribute;
}
}
for key, value in attributes {
if !isset attrs[key] {
let attrs[key] = value;
}
}
let escaper = <EscaperInterface> self::getEscaper(attributes);
unset attrs["escape"];
let newCode = code;
for key, value in attrs {
if typeof key == "string" && value !== null {
if unlikely (typeof value == "array" || typeof value == "resource") {
throw new Exception(
"Value at index: '" . key . "' type: '" . gettype(value) . "' cannot be rendered"
);
}
if escaper {
let escaped = escaper->escapeHtmlAttr(value);
} else {
let escaped = value;
}
let newCode .= " " . key . "=\"" . escaped . "\"";
}
}
return newCode;
}
/**
* Renders the title with title tags. The title is automaticall escaped
*/
public static function renderTitle(bool prepend = true, bool append = true) -> string
{
return "<title>" . self::getTitle(prepend, append) . "</title>" . PHP_EOL;
}
/**
* Resets the request and internal values to avoid those fields will have
* any default value.
*
* @deprecated Will be removed in 4.0.0
*/
deprecated public static function resetInput() -> void
{
let self::displayValues = [],
self::documentTitle = null,
self::documentAppendTitle = [],
self::documentPrependTitle = [],
self::documentTitleSeparator = null;
}
/**
* Builds a HTML input[type="search"] tag
*/
public static function searchField(var parameters) -> string
{
return self::inputField("search", parameters);
}
/**
* Builds a HTML SELECT tag using a Phalcon\Mvc\Model resultset as options
*/
public static function select(var parameters, data = null) -> string
{
return Select::selectField(parameters, data);
}
/**
* Builds a HTML SELECT tag using a PHP array for options
*/
public static function selectStatic(parameters, data = null) -> string
{
return Select::selectField(parameters, data);
}
/**
* Set autoescape mode in generated html
*/
public static function setAutoescape(bool autoescape) -> void
{
let self::autoEscape = autoescape;
}
/**
* Assigns default values to generated tags by helpers
*/
public static function setDefault(string! id, value) -> void
{
if value !== null {
if unlikely (typeof value == "array" || typeof value == "object") {
throw new Exception(
"Only scalar values can be assigned to UI components"
);
}
}
let self::displayValues[id] = value;
}
/**
* Assigns default values to generated tags by helpers
*/
public static function setDefaults(array! values, bool merge = false) -> void
{
if merge && typeof self::displayValues == "array" {
let self::displayValues = array_merge(self::displayValues, values);
} else {
let self::displayValues = values;
}
}
/**
* Sets the dependency injector container.
*/
public static function setDI(<DiInterface> container) -> void
{
let self::container = container;
}
/**
* Set the document type of content
*/
public static function setDocType(int doctype) -> void
{
if doctype < self::HTML32 || doctype > self::XHTML5 {
let self::documentType = self::HTML5;
} else {
let self::documentType = doctype;
}
}
/**
* Set the title of view content
*/
public static function setTitle(string title) -> void
{
let self::documentTitle = title;
}
/**
* Set the title separator of view content
*/
public static function setTitleSeparator(string titleSeparator) -> void
{
let self::documentTitleSeparator = titleSeparator;
}
/**
* Builds a LINK[rel="stylesheet"] tag
*/
public static function stylesheetLink(var parameters = null, bool local = true) -> string
{
var params, code;
if typeof parameters != "array" {
let params = [parameters, local];
} else {
let params = parameters;
}
if isset params[1] {
let local = (bool) params[1];
} else {
if isset params["local"] {
let local = (bool) params["local"];
unset params["local"];
}
}
if !isset params["type"] {
let params["type"] = "text/css";
}
if !isset params["href"] {
if isset params[0] {
let params["href"] = params[0];
} else {
let params["href"] = "";
}
}
/**
* URLs are generated through the "url" service
*/
if local {
let params["href"] = self::getUrlService()->getStatic(
params["href"]
);
}
if !isset params["rel"] {
let params["rel"] = "stylesheet";
}
let code = self::renderAttributes("<link", params);
/**
* Check if Doctype is XHTML
*/
if self::documentType > self::HTML5 {
let code .= " />" . PHP_EOL;
} else {
let code .= ">" . PHP_EOL;
}
return code;
}
/**
* Builds a HTML input[type="submit"] tag
*/
public static function submitButton(var parameters) -> string
{
return self::inputField("submit", parameters, true);
}
/**
* Builds a HTML tag
*/
public static function tagHtml(
string tagName,
var parameters = null,
bool selfClose = false,
bool onlyStart = false,
bool useEol = false
) -> string
{
var params, localCode;
if typeof parameters != "array" {
let params = [parameters];
} else {
let params = parameters;
}
let localCode = self::renderAttributes("<" . tagName, params);
/**
* Check if Doctype is XHTML
*/
if self::documentType > self::HTML5 {
if selfClose {
let localCode .= " />";
} else {
let localCode .= ">";
}
} else {
if onlyStart {
let localCode .= ">";
} else {
let localCode .= "></" . tagName . ">";
}
}
if useEol {
let localCode .= PHP_EOL;