Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit ea23993

Browse files
committed
Fixes #100 - Missing documentation for Zend\View\Helper\HtmlTag
1 parent 8bad7f9 commit ea23993

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

Diff for: doc/book/helpers/html-tag.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# HtmlTag
2+
3+
The `HtmlTag` helper is used to **create the root of a HTML document**, the open
4+
and close tags for the `<html>` element.
5+
6+
## Basic Usage
7+
8+
```php
9+
<?= $this->htmlTag(['lang' => 'en'])->openTag() ?>
10+
<!-- Some HTML -->
11+
<?= $this->htmlTag()->closeTag() ?>
12+
```
13+
14+
Output:
15+
16+
```html
17+
<html lang="en">
18+
<!-- Some HTML -->
19+
</html>
20+
```
21+
22+
## Using Attributes
23+
24+
### Set a single Attribute
25+
26+
```php fct_label="Invoke Usage"
27+
$this->htmlTag(['lang' => 'en']);
28+
29+
echo $this->htmlTag()->openTag(); // <html lang="en">
30+
```
31+
32+
```php fct_label="Setter Usage"
33+
$this->htmlTag()->setAttribute('lang', 'en');
34+
35+
echo $this->htmlTag()->openTag(); // <html lang="en">
36+
```
37+
38+
### Set multiple Attributes
39+
40+
```php fct_label="Invoke Usage"
41+
$this->htmlTag(['lang' => 'en', 'id' => 'example']);
42+
43+
echo $this->htmlTag()->openTag(); // <html lang="en" id="example">
44+
```
45+
46+
```php fct_label="Setter Usage"
47+
$this->htmlTag()->setAttributes(['lang' => 'en', 'id' => 'example']);
48+
49+
echo $this->htmlTag()->openTag(); // <html lang="en" id="example">
50+
```
51+
52+
### Get current Value
53+
54+
To get the current value, use the `getAttributes()` method.
55+
56+
```php
57+
$this->htmlTag(['lang' => 'en', 'id' => 'example']);
58+
59+
var_dump($this->htmlTag()->getAttributes()); // ['lang' => 'en', 'id' => 'example']
60+
```
61+
62+
### Default Value
63+
64+
The default value is an empty `array` that means no attributes are set.
65+
66+
## Using Namespace
67+
68+
The `HtmlTag` helper can automatically add the [XHTML namespace](http://www.w3.org/1999/xhtml/)
69+
for XHTML documents. To use this functionality, the [`Doctype` helper](doctype.md)
70+
is used.
71+
72+
The namespace is added only if the document type is set to an XHTML type and use
73+
is enabled:
74+
75+
```php
76+
// Set doctype to XHTML
77+
$this->doctype(Zend\View\Helper\Doctype::XHTML1_STRICT);
78+
79+
// Add namespace to open tag
80+
$this->htmlTag()->setUseNamespaces(true);
81+
82+
// Output
83+
echo $this->htmlTag()->openTag(); // <html xmlns="http://www.w3.org/1999/xhtml">
84+
```
85+
86+
### Get current Value
87+
88+
To get the current value, use the `getUseNamespaces()` method.
89+
90+
```php
91+
$this->htmlTag()->setUseNamespaces(true);
92+
93+
var_dump($this->htmlTag()->getUseNamespaces()); // true
94+
```
95+
96+
### Default Value
97+
98+
The default value is `false` that means no namespace is added as attribute.

Diff for: doc/book/helpers/intro.md

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ for, and rendering, the various HTML `<head>` tags, such as `HeadTitle`,
6868
- [HeadTitle](head-title.md)
6969
- [HtmlList](html-list.md)
7070
- [HTML Object Plugins](html-object.md)
71+
- [HtmlTag](html-tag.md)
7172
- [Identity](identity.md)
7273
- [InlineScript](inline-script.md)
7374
- [JSON](json.md)

Diff for: mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pages:
2222
- HeadTitle: helpers/head-title.md
2323
- HtmlList: helpers/html-list.md
2424
- HtmlObject: helpers/html-object.md
25+
- HtmlTag: helpers/html-tag.md
2526
- Identity: helpers/identity.md
2627
- InlineScript: helpers/inline-script.md
2728
- Json: helpers/json.md

0 commit comments

Comments
 (0)