Skip to content

Commit 10bd5d9

Browse files
committed
Add closeTag as optional parameter to renderStartTag()
1 parent ed00387 commit 10bd5d9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/TgUtils/Html.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ class Html {
99

1010
/**
1111
* Returns the opening tag with the given attributes.
12-
* @param string $tagName - the name of the tag
12+
* @param string $tagName - the name of the tag
1313
* @param array $attributes - the attributes to be rendered (values will be encoded accordingly)
14+
* @param array $closeTag - close the tag immediately by including the slash, e.g. <br/>
1415
* @return string the opening HTML tag rendered
1516
*/
16-
public static function renderStartTag($tagName, $attributes = array()) {
17+
public static function renderStartTag($tagName, $attributes = array(), $closeTag = FALSE) {
1718
$rc = '<'.$tagName;
1819
foreach ($attributes AS $name => $value) {
1920
if (is_array($value)) $value = implode(' ', $value);
@@ -22,6 +23,7 @@ public static function renderStartTag($tagName, $attributes = array()) {
2223
}
2324
}
2425

26+
if ($closeTag) $rc .= '/';
2527
$rc .= '>';
2628
return $rc;
2729
}
@@ -34,4 +36,4 @@ public static function renderStartTag($tagName, $attributes = array()) {
3436
public static function renderEndTag($tagName) {
3537
return '</'.$tagName. '>';
3638
}
37-
}
39+
}

0 commit comments

Comments
 (0)