mirror of
https://github.com/smarty-php/smarty.git
synced 2025-07-29 15:37:14 +02:00
add count and debug_print_var modifier doc (#1116)
This commit is contained in:
@ -12,10 +12,12 @@ These parameters follow the modifier name and are separated by a `:`
|
||||
|
||||
- [capitalize](language-modifier-capitalize.md)
|
||||
- [cat](language-modifier-cat.md)
|
||||
- [count](language-modifier-count.md)
|
||||
- [count_characters](language-modifier-count-characters.md)
|
||||
- [count_paragraphs](language-modifier-count-paragraphs.md)
|
||||
- [count_sentences](language-modifier-count-sentences.md)
|
||||
- [count_words](language-modifier-count-words.md)
|
||||
- [debug_print_var](language-modifier-debug-print-var.md)
|
||||
- [date_format](language-modifier-date-format.md)
|
||||
- [default](language-modifier-default.md)
|
||||
- [escape](language-modifier-escape.md)
|
||||
|
21
docs/designers/language-modifiers/language-modifier-count.md
Normal file
21
docs/designers/language-modifiers/language-modifier-count.md
Normal file
@ -0,0 +1,21 @@
|
||||
# count
|
||||
|
||||
Returns the number of elements in an array (or Countable object). Will return 0 for null.
|
||||
Returns 1 for any other type (such as a string).
|
||||
|
||||
If the optional mode parameter is set to 1, count() will recursively count the array.
|
||||
This is particularly useful for counting all the elements of a multidimensional array.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{if $myVar|count > 3}4 or more{/if}
|
||||
{if count($myVar) > 3}4 or more{/if}
|
||||
```
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|--------------------------------------------------------|
|
||||
| 1 | int | No | If set to 1, count() will recursively count the array. |
|
||||
|
@ -0,0 +1,26 @@
|
||||
# debug_print_var
|
||||
|
||||
|
||||
|
||||
Returns the value of the given variable in a human-readable format in HTML.
|
||||
Used in the [debug console](../chapter-debugging-console.md), but you can also use it in your template
|
||||
while developing to see what is going on under the hood.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> Use for debugging only! Since you may accidentally reveal sensitive information or introduce vulnerabilities such as XSS using this
|
||||
method never use it in production.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{$myVar|debug_print_var}
|
||||
```
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|------------------------------------------------------------------------|
|
||||
| 1 | int | No | maximum recursion depth if $var is an array or object (defaults to 10) |
|
||||
| 2 | int | No | maximum string length if $var is a string (defaults to 40) |
|
||||
|
@ -49,10 +49,12 @@ nav:
|
||||
- 'Introduction': 'designers/language-modifiers/index.md'
|
||||
- 'capitalize': 'designers/language-modifiers/language-modifier-capitalize.md'
|
||||
- 'cat': 'designers/language-modifiers/language-modifier-cat.md'
|
||||
- 'count': 'designers/language-modifiers/language-modifier-count.md'
|
||||
- 'count_characters': 'designers/language-modifiers/language-modifier-count-characters.md'
|
||||
- 'count_paragraphs': 'designers/language-modifiers/language-modifier-count-paragraphs.md'
|
||||
- 'count_sentences': 'designers/language-modifiers/language-modifier-count-sentences.md'
|
||||
- 'count_words': 'designers/language-modifiers/language-modifier-count-words.md'
|
||||
- 'debug_print_var': 'designers/language-modifiers/language-modifier-debug-print-var.md'
|
||||
- 'date_format': 'designers/language-modifiers/language-modifier-date-format.md'
|
||||
- 'default': 'designers/language-modifiers/language-modifier-default.md'
|
||||
- 'escape': 'designers/language-modifiers/language-modifier-escape.md'
|
||||
@ -122,4 +124,4 @@ nav:
|
||||
- 'programmers/caching.md'
|
||||
- 'programmers/resources.md'
|
||||
- 'programmers/advanced-features.md'
|
||||
- 'programmers/plugins.md'
|
||||
- 'programmers/plugins.md'
|
||||
|
Reference in New Issue
Block a user