Skip to content

Commit 820ae7e

Browse files
committed
Unify documentation of template plugins
1 parent 6055e75 commit 820ae7e

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

docs/view/template-plugins.md

+37-37
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## `{anchor}`
44

5-
The `anchor` template plugin creates `a` HTML elements.
5+
The `{anchor}` template plugin creates `a` HTML elements.
66
The easiest way to use the template plugin is to pass it an instance of `ITitledLinkObject`:
77

88
```smarty
@@ -45,7 +45,7 @@ is sufficient if `Entry::getPopoverLinkClass()` returns `blogEntryLink`.
4545

4646
## `{anchorAttributes}`
4747

48-
`anchorAttributes` compliments the `StringUtil::getAnchorTagAttributes(string, bool): string` method.
48+
`{anchorAttributes}` compliments the `StringUtil::getAnchorTagAttributes(string, bool): string` method.
4949
It allows to easily generate the necessary attributes for an anchor tag based off the destination URL.
5050

5151
```smarty
@@ -61,7 +61,7 @@ It allows to easily generate the necessary attributes for an anchor tag based of
6161

6262
## `{append}`
6363

64-
If a string should be appended to the value of a variable, `append` can be used:
64+
If a string should be appended to the value of a variable, `{append}` can be used:
6565

6666
```smarty
6767
{assign var=templateVariable value='newValue'}
@@ -73,13 +73,13 @@ If a string should be appended to the value of a variable, `append` can be used:
7373
{$templateVariable} {* now prints 'newValue2 *}
7474
```
7575

76-
If the variables does not exist yet, `append` creates a new one with the given value.
77-
If `append` is used on an array as the variable, the value is appended to all elements of the array.
76+
If the variables does not exist yet, `{append}` creates a new one with the given value.
77+
If `{append}` is used on an array as the variable, the value is appended to all elements of the array.
7878

7979

8080
## `{assign}`
8181

82-
New template variables can be declared and new values can be assigned to existing template variables using `assign`:
82+
New template variables can be declared and new values can be assigned to existing template variables using `{assign}`:
8383

8484
```smarty
8585
{assign var=templateVariable value='newValue'}
@@ -90,8 +90,8 @@ New template variables can be declared and new values can be assigned to existin
9090

9191
## `{capture}`
9292

93-
In some situations, `assign` is not sufficient to assign values to variables in templates if the value is complex.
94-
Instead, `capture` can be used:
93+
In some situations, `{assign}` is not sufficient to assign values to variables in templates if the value is complex.
94+
Instead, `{capture}` can be used:
9595

9696
```smarty
9797
{capture var=templateVariable}
@@ -106,7 +106,7 @@ Instead, `capture` can be used:
106106

107107
## `{counter}`
108108

109-
`counter` can be used to generate and optionally print a counter:
109+
`{counter}` can be used to generate and optionally print a counter:
110110

111111
```smarty
112112
{counter name=fooCounter print=true} {* prints '1' *}
@@ -130,7 +130,7 @@ Counter supports the following attributes:
130130
| `start` | start counter value; `1` by default |
131131

132132

133-
## <span class="label label-info">5.4+</span> `csrfToken`
133+
## `{csrfToken}`
134134

135135
`{csrfToken}` prints out the session's CSRF token (“Security Token”).
136136

@@ -149,7 +149,7 @@ Please [check the implementation](https://github.com/WoltLab/WCF/blob/master/wcf
149149

150150
## `{cycle}`
151151

152-
`cycle` can be used to cycle between different values:
152+
`{cycle}` can be used to cycle between different values:
153153

154154
```smarty
155155
{cycle name=fooCycle values='bar,baz'} {* prints 'bar' *}
@@ -161,7 +161,7 @@ Please [check the implementation](https://github.com/WoltLab/WCF/blob/master/wcf
161161
{cycle name=fooCycle} {* prints 'bar' *}
162162
```
163163

164-
!!! info "The values attribute only has to be present for the first call. If `cycle` is used in a loop, the presence of the same values in consecutive calls has no effect. Only once the values change, the cycle is reset."
164+
!!! info "The values attribute only has to be present for the first call. If `{cycle}` is used in a loop, the presence of the same values in consecutive calls has no effect. Only once the values change, the cycle is reset."
165165

166166
| Attribute | Description |
167167
|-----------|-------------|
@@ -176,7 +176,7 @@ Please [check the implementation](https://github.com/WoltLab/WCF/blob/master/wcf
176176

177177
## `{dateInterval}`
178178

179-
`dateInterval` calculates the difference between two unix timestamps and generated a textual date interval.
179+
`{dateInterval}` calculates the difference between two unix timestamps and generated a textual date interval.
180180

181181
```smarty
182182
{dateInterval start=$startTimestamp end=$endTimestamp full=true format='sentence'}
@@ -192,7 +192,7 @@ Please [check the implementation](https://github.com/WoltLab/WCF/blob/master/wcf
192192

193193
## `{event}`
194194

195-
`event` provides extension points in templates that [template listeners](../package/pip/template-listener.md) can use.
195+
`{event}` provides extension points in templates that [template listeners](../package/pip/template-listener.md) can use.
196196

197197
```smarty
198198
{event name='foo'}
@@ -224,7 +224,7 @@ One prominent example is a template event:
224224
```
225225

226226
In this example, if `$foo !== 'bar'`, the list will not be shown, regardless of the additional template code provided by template listeners.
227-
In such a situation, `hascontent` has to be used:
227+
In such a situation, `{hascontent}` has to be used:
228228

229229
```smarty
230230
{hascontent}
@@ -240,10 +240,10 @@ In such a situation, `hascontent` has to be used:
240240
{/hascontent}
241241
```
242242

243-
If the part of the template wrapped in the `content` tags has any (trimmed) content, the part of the template wrapped by `hascontent` tags is shown (including the part wrapped by the `content` tags), otherwise nothing is shown.
243+
If the part of the template wrapped in the `{content}` tags has any (trimmed) content, the part of the template wrapped by `{hascontent}` tags is shown (including the part wrapped by the `{content}` tags), otherwise nothing is shown.
244244
Thus, this construct avoids an empty list compared to the `if` solution above.
245245

246-
Like `foreach`, `hascontent` also supports an `else` part:
246+
Like `{foreach}`, `{hascontent}` also supports an `else` part:
247247

248248
```smarty
249249
{hascontent}
@@ -260,7 +260,7 @@ Like `foreach`, `hascontent` also supports an `else` part:
260260

261261
## `{htmlCheckboxes}`
262262

263-
`htmlCheckboxes` generates a list of HTML checkboxes.
263+
`{htmlCheckboxes}` generates a list of HTML checkboxes.
264264

265265
```smarty
266266
{htmlCheckboxes name=foo options=$fooOptions selected=$currentFoo}
@@ -282,7 +282,7 @@ Like `foreach`, `hascontent` also supports an `else` part:
282282

283283
## `{htmlOptions}`
284284

285-
`htmlOptions` generates an `select` HTML element.
285+
`{htmlOptions}` generates an `<select>` HTML element.
286286

287287
```smarty
288288
{htmlOptions name='foo' options=$options selected=$selected}
@@ -303,7 +303,7 @@ Like `foreach`, `hascontent` also supports an `else` part:
303303
| `options` | array selectable options with the key used as `value` attribute and the value as the option label; if a value is an array, an `optgroup` is generated with the array key as the `optgroup` label |
304304
| `selected` | current selected value(s) |
305305

306-
All additional attributes are added as attributes of the `select` HTML element.
306+
All additional attributes are added as attributes of the `<select>` HTML element.
307307

308308

309309
## `{icon}`
@@ -325,7 +325,7 @@ All additional attributes are added as attributes of the `select` HTML element.
325325

326326
## `{implode}`
327327

328-
`implodes` transforms an array into a string and prints it.
328+
`{implodes}` transforms an array into a string and prints it.
329329

330330
```smarty
331331
{implode from=$array key=key item=item glue=";"}{$key}: {$value}{/implode}
@@ -341,7 +341,7 @@ All additional attributes are added as attributes of the `select` HTML element.
341341

342342
## `{js}`
343343

344-
`js` generates script tags based on whether `ENABLE_DEBUG_MODE` and `VISITOR_USE_TINY_BUILD` are enabled.
344+
`{js}` generates script tags based on whether `ENABLE_DEBUG_MODE` and `VISITOR_USE_TINY_BUILD` are enabled.
345345

346346
```smarty
347347
{js application='wbb' file='WBB'} {* generates 'http://example.com/js/WBB.js' *}
@@ -365,7 +365,7 @@ All additional attributes are added as attributes of the `select` HTML element.
365365

366366
## `{jslang}`
367367

368-
`jslang` works like [`lang`](#lang) with the difference that the resulting string is automatically passed through [`encodeJS`](#encodejs).
368+
`{jslang}` works like [`lang`](#lang) with the difference that the resulting string is automatically passed through [`encodeJS`](#encodejs).
369369

370370
```smarty
371371
require(['Language', /* … */], function(Language, /* … */) {
@@ -378,9 +378,9 @@ require(['Language', /* … */], function(Language, /* … */) {
378378
```
379379

380380

381-
## <span class="label label-info">6.0+</span> `{jsphrase}`
381+
## `{jsphrase}`
382382

383-
`jsphrase` generates the necessary JavaScript code to register a phrase in the JavaScript language store.
383+
`{jsphrase}` generates the necessary JavaScript code to register a phrase in the JavaScript language store.
384384
This plugin only supports static phrase names.
385385
If a dynamic phrase should be registered, the [`jslang`](#jslang) plugin needs to be used.
386386

@@ -395,7 +395,7 @@ If a dynamic phrase should be registered, the [`jslang`](#jslang) plugin needs t
395395

396396
## `{lang}`
397397

398-
`lang` replaces a language items with its value.
398+
`{lang}` replaces a language items with its value.
399399

400400
```smarty
401401
{lang}foo.bar.baz{/lang}
@@ -418,7 +418,7 @@ All additional attributes are available when parsing the language item.
418418

419419
## `{link}`
420420

421-
`link` generates internal links using `LinkHandler`.
421+
`{link}` generates internal links using `LinkHandler`.
422422

423423
```smarty
424424
<a href="{link controller='FooList' application='bar'}param1=2&param2=A{/link}">Foo</a>
@@ -434,15 +434,15 @@ All additional attributes are available when parsing the language item.
434434
Additional attributes are passed to `LinkHandler::getLink()`.
435435

436436

437-
## <span class="label label-info">5.4+</span> `objectAction`
437+
## `{objectAction}`
438438

439-
`objectAction` generates action buttons to be used in combination with the [`WoltLabSuite/Core/Ui/Object/Action` API](../migration/wsc53/javascript.md#wcfactiondelete-and-wcfactiontoggle).
439+
`{objectAction}` generates action buttons to be used in combination with the [`WoltLabSuite/Core/Ui/Object/Action` API](../migration/wsc53/javascript.md#wcfactiondelete-and-wcfactiontoggle).
440440
For detailed information on its usage, we refer to the extensive documentation in the [`ObjectActionFunctionTemplatePlugin` class](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php) itself.
441441

442442

443443
## `{page}`
444444

445-
`page` generates an internal link to a CMS page.
445+
`{page}` generates an internal link to a CMS page.
446446

447447
```smarty
448448
{page}com.woltlab.wcf.CookiePolicy{/page}
@@ -465,7 +465,7 @@ For detailed information on its usage, we refer to the extensive documentation i
465465

466466
!!! info "This template plugin has been deprecated in WoltLab Suite 6.0."
467467

468-
`pages` generates a pagination.
468+
`{pages}` generates a pagination.
469469

470470
```smarty
471471
{pages controller='FooList' link="pageNo=%d" print=true assign=pagesLinks} {* prints pagination *}
@@ -488,7 +488,7 @@ For detailed information on its usage, we refer to the extensive documentation i
488488

489489
## `{plural}`
490490

491-
`plural` allows to easily select the correct plural form of a phrase based on a given `value`.
491+
`{plural}` allows to easily select the correct plural form of a phrase based on a given `value`.
492492
The pluralization logic follows the [Unicode Language Plural Rules](https://unicode-org.github.io/cldr-staging/charts/37/supplemental/language_plural_rules.md) for cardinal numbers.
493493

494494
The `#` placeholder within the resulting phrase is replaced by the `value`.
@@ -544,7 +544,7 @@ Note the difference between `1` (exactly `1`) and `one` (ending in `1`, except e
544544

545545
## `{prepend}`
546546

547-
If a string should be prepended to the value of a variable, `prepend` can be used:
547+
If a string should be prepended to the value of a variable, `{prepend}` can be used:
548548

549549
```smarty
550550
{assign var=templateVariable value='newValue'}
@@ -556,13 +556,13 @@ If a string should be prepended to the value of a variable, `prepend` can be use
556556
{$templateVariable} {* now prints '2newValue' *}
557557
```
558558

559-
If the variables does not exist yet, `prepend` creates a new one with the given value.
560-
If `prepend` is used on an array as the variable, the value is prepended to all elements of the array.
559+
If the variables does not exist yet, `{prepend}` creates a new one with the given value.
560+
If `{prepend}` is used on an array as the variable, the value is prepended to all elements of the array.
561561

562562

563563
## `{time}`
564564

565-
`time` allows to output times in different (human readable) formats.
565+
`{time}` allows to output times in different (human readable) formats.
566566
Acceptables inputs are either a `\DateTimeInterface` or an integer representing a Unix timestamp.
567567

568568
```smarty
@@ -589,7 +589,7 @@ Acceptables inputs are either a `\DateTimeInterface` or an integer representing
589589

590590
## `{user}`
591591

592-
`user` generates links to user profiles.
592+
`{user}` generates links to user profiles.
593593
The mandatory `object` parameter requires an instances of `UserProfile`.
594594
The optional `type` parameter is responsible for what the generated link contains:
595595

0 commit comments

Comments
 (0)