Skip to content

Commit d043b63

Browse files
committed
add count and debug_print_var modifier doc
1 parent 5cb412d commit d043b63

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

docs/designers/language-modifiers/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ These parameters follow the modifier name and are separated by a `:`
1212

1313
- [capitalize](language-modifier-capitalize.md)
1414
- [cat](language-modifier-cat.md)
15+
- [count](language-modifier-count.md)
1516
- [count_characters](language-modifier-count-characters.md)
1617
- [count_paragraphs](language-modifier-count-paragraphs.md)
1718
- [count_sentences](language-modifier-count-sentences.md)
1819
- [count_words](language-modifier-count-words.md)
20+
- [debug_print_var](language-modifier-debug-print-var.md)
1921
- [date_format](language-modifier-date-format.md)
2022
- [default](language-modifier-default.md)
2123
- [escape](language-modifier-escape.md)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# count
2+
3+
Returns the number of elements in an array (or Countable object). Will return 0 for null.
4+
Returns 1 for any other type (such as a string).
5+
6+
If the optional mode parameter is set to 1, count() will recursively count the array.
7+
This is particularly useful for counting all the elements of a multidimensional array.
8+
9+
## Basic usage
10+
```smarty
11+
{if $myVar|count > 3}4 or more{/if}
12+
{if count($myVar) > 3}4 or more{/if}
13+
```
14+
15+
16+
## Parameters
17+
18+
| Parameter | Type | Required | Description |
19+
|-----------|------|----------|--------------------------------------------------------|
20+
| 1 | int | No | If set to 1, count() will recursively count the array. |
21+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# debug_print_var
2+
3+
4+
5+
Returns the value of the given variable in a human-readable format in HTML.
6+
Used in the [debug console](../chapter-debugging-console.md), but you can also use it in your template
7+
while developing to see what is going on under the hood.
8+
9+
> **Note**
10+
>
11+
> Use for debugging only! Since you may accidentally reveal sensitive information or introduce vulnerabilities such as XSS using this
12+
method never use it in production.
13+
14+
## Basic usage
15+
```smarty
16+
{$myVar|debug_print_var}
17+
```
18+
19+
20+
## Parameters
21+
22+
| Parameter | Type | Required | Description |
23+
|-----------|------|----------|------------------------------------------------------------------------|
24+
| 1 | int | No | maximum recursion depth if $var is an array or object (defaults to 10) |
25+
| 2 | int | No | maximum string length if $var is a string (defaults to 40) |
26+

mkdocs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ nav:
4949
- 'Introduction': 'designers/language-modifiers/index.md'
5050
- 'capitalize': 'designers/language-modifiers/language-modifier-capitalize.md'
5151
- 'cat': 'designers/language-modifiers/language-modifier-cat.md'
52+
- 'count': 'designers/language-modifiers/language-modifier-count.md'
5253
- 'count_characters': 'designers/language-modifiers/language-modifier-count-characters.md'
5354
- 'count_paragraphs': 'designers/language-modifiers/language-modifier-count-paragraphs.md'
5455
- 'count_sentences': 'designers/language-modifiers/language-modifier-count-sentences.md'
5556
- 'count_words': 'designers/language-modifiers/language-modifier-count-words.md'
57+
- 'debug_print_var': 'designers/language-modifiers/language-modifier-debug-print-var.md'
5658
- 'date_format': 'designers/language-modifiers/language-modifier-date-format.md'
5759
- 'default': 'designers/language-modifiers/language-modifier-default.md'
5860
- 'escape': 'designers/language-modifiers/language-modifier-escape.md'
@@ -122,4 +124,4 @@ nav:
122124
- 'programmers/caching.md'
123125
- 'programmers/resources.md'
124126
- 'programmers/advanced-features.md'
125-
- 'programmers/plugins.md'
127+
- 'programmers/plugins.md'

0 commit comments

Comments
 (0)