summaryrefslogtreecommitdiff
path: root/docs/designers/language-modifiers
diff options
context:
space:
mode:
Diffstat (limited to 'docs/designers/language-modifiers')
-rw-r--r--docs/designers/language-modifiers/index.md122
-rw-r--r--docs/designers/language-modifiers/language-modifier-capitalize.md38
-rw-r--r--docs/designers/language-modifiers/language-modifier-cat.md33
-rw-r--r--docs/designers/language-modifiers/language-modifier-count-characters.md40
-rw-r--r--docs/designers/language-modifiers/language-modifier-count-paragraphs.md31
-rw-r--r--docs/designers/language-modifiers/language-modifier-count-sentences.md32
-rw-r--r--docs/designers/language-modifiers/language-modifier-count-words.md32
-rw-r--r--docs/designers/language-modifiers/language-modifier-date-format.md190
-rw-r--r--docs/designers/language-modifiers/language-modifier-default.md50
-rw-r--r--docs/designers/language-modifiers/language-modifier-escape.md98
-rw-r--r--docs/designers/language-modifiers/language-modifier-from-charset.md19
-rw-r--r--docs/designers/language-modifiers/language-modifier-indent.md73
-rw-r--r--docs/designers/language-modifiers/language-modifier-lower.md39
-rw-r--r--docs/designers/language-modifiers/language-modifier-nl2br.md40
-rw-r--r--docs/designers/language-modifiers/language-modifier-regex-replace.md52
-rw-r--r--docs/designers/language-modifiers/language-modifier-replace.md53
-rw-r--r--docs/designers/language-modifiers/language-modifier-spacify.md50
-rw-r--r--docs/designers/language-modifiers/language-modifier-string-format.md48
-rw-r--r--docs/designers/language-modifiers/language-modifier-strip-tags.md57
-rw-r--r--docs/designers/language-modifiers/language-modifier-strip.md50
-rw-r--r--docs/designers/language-modifiers/language-modifier-to-charset.md17
-rw-r--r--docs/designers/language-modifiers/language-modifier-truncate.md71
-rw-r--r--docs/designers/language-modifiers/language-modifier-unescape.md52
-rw-r--r--docs/designers/language-modifiers/language-modifier-upper.md38
-rw-r--r--docs/designers/language-modifiers/language-modifier-wordwrap.md84
25 files changed, 791 insertions, 618 deletions
diff --git a/docs/designers/language-modifiers/index.md b/docs/designers/language-modifiers/index.md
new file mode 100644
index 00000000..c9aeef88
--- /dev/null
+++ b/docs/designers/language-modifiers/index.md
@@ -0,0 +1,122 @@
+# Variable Modifiers
+
+Variable modifiers can be applied to
+[variables](../language-variables/index.md), [custom functions](../language-custom-functions/index.md)
+or strings. To apply a modifier,
+specify the value followed by a `|` (pipe) and the modifier name. A
+modifier may accept additional parameters that affect its behavior.
+These parameters follow the modifier name and are separated by a `:`
+(colon). Also, *all php-functions can be used as modifiers implicitly*
+(more below) and modifiers can be
+[combined](../language-combining-modifiers.md).
+
+- [capitalize](language-modifier-capitalize.md)
+- [cat](language-modifier-cat.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)
+- [date_format](language-modifier-date-format.md)
+- [default](language-modifier-default.md)
+- [escape](language-modifier-escape.md)
+- [from_charset](language-modifier-from-charset.md)
+- [indent](language-modifier-indent.md)
+- [lower](language-modifier-lower.md)
+- [nl2br](language-modifier-nl2br.md)
+- [regex_replace](language-modifier-regex-replace.md)
+- [replace](language-modifier-replace.md)
+- [spacify](language-modifier-spacify.md)
+- [string_format](language-modifier-string-format.md)
+- [strip](language-modifier-strip.md)
+- [strip_tags](language-modifier-strip-tags.md)
+- [to_charset](language-modifier-to-charset.md)
+- [truncate](language-modifier-truncate.md)
+- [unescape](language-modifier-unescape.md)
+- [upper](language-modifier-upper.md)
+- [wordwrap](language-modifier-wordwrap.md)
+
+## Examples
+
+```smarty
+{* apply modifier to a variable *}
+{$title|upper}
+
+{* modifier with parameters *}
+{$title|truncate:40:"..."}
+
+{* apply modifier to a function parameter *}
+{html_table loop=$myvar|upper}
+
+{* with parameters *}
+{html_table loop=$myvar|truncate:40:"..."}
+
+{* apply modifier to literal string *}
+{"foobar"|upper}
+
+{* using date_format to format the current date *}
+{$smarty.now|date_format:"%Y/%m/%d"}
+
+{* apply modifier to a custom function *}
+{mailto|upper address="smarty@example.com"}
+
+{* using php's str_repeat *}
+{"="|str_repeat:80}
+
+{* php's count *}
+{$myArray|@count}
+
+{* this will uppercase and truncate the whole array *}
+<select name="name_id">
+{html_options output=$my_array|upper|truncate:20}
+</select>
+```
+
+- Modifiers can be applied to any type of variables, including arrays
+ and objects.
+
+ > **Note**
+ >
+ > The default behavior was changed with Smarty 3. In Smarty 2.x, you
+ > had to use an "`@`" symbol to apply a modifier to an array, such
+ > as `{$articleTitle|@count}`. With Smarty 3, the "`@`" is no
+ > longer necessary, and is ignored.
+ >
+ > If you want a modifier to apply to each individual item of an
+ > array, you will either need to loop the array in the template, or
+ > provide for this functionality inside your modifier function.
+
+ > **Note**
+ >
+ > Second, in Smarty 2.x, modifiers were applied to the result of
+ > math expressions like `{8+2}`, meaning that
+ > `{8+2|count_characters}` would give `2`, as 8+2=10 and 10 is two
+ > characters long. With Smarty 3, modifiers are applied to the
+ > variables or atomic expressions before executing the calculations,
+ > so since 2 is one character long, `{8+2|count_characters}`
+ > gives 9. To get the old result use parentheses like
+ > `{(8+2)|count_characters}`.
+
+- Modifiers are autoloaded from the
+ [`$plugins_dir`](../../programmers/api-variables/variable-plugins-dir.md) or can be registered
+ explicitly with the [`registerPlugin()`](../../programmers/api-functions/api-register-plugin.md)
+ function. The later is useful for sharing a function between php
+ scripts and smarty templates.
+
+- All php-functions can be used as modifiers implicitly, as
+ demonstrated in the example above. However, using php-functions as
+ modifiers has two little pitfalls:
+
+ - First - sometimes the order of the function-parameters is not
+ the desirable one. Formatting `$foo` with
+ `{"%2.f"|sprintf:$foo}` actually works, but asks for the more
+ intuitive, like `{$foo|string_format:"%2.f"}` that is provided
+ by the Smarty distribution.
+
+ - Secondly - if security is enabled, all php-functions that are to
+ be used as modifiers have to be declared trusted in the
+ `$modifiers` property of the security policy. See the
+ [Security](../../programmers/advanced-features/advanced-features-security.md) section for details.
+
+See also [`registerPlugin()`](../../programmers/api-functions/api-register-plugin.md), [combining
+modifiers](../language-combining-modifiers.md). and [extending smarty with
+plugins](../../programmers/plugins.md)
diff --git a/docs/designers/language-modifiers/language-modifier-capitalize.md b/docs/designers/language-modifiers/language-modifier-capitalize.md
index 03e9d8c3..0368c7b3 100644
--- a/docs/designers/language-modifiers/language-modifier-capitalize.md
+++ b/docs/designers/language-modifiers/language-modifier-capitalize.md
@@ -1,41 +1,49 @@
-capitalize {#language.modifier.capitalize}
-==========
+# capitalize
This is used to capitalize the first letter of all words in a variable.
This is similar to the PHP [`ucwords()`](https://www.php.net/ucwords)
function.
- Parameter Position Type Required Default Description
- -------------------- --------- ---------- --------- -----------------------------------------------------------------------------------------------------------
- 1 boolean No FALSE This determines whether or not words with digits will be uppercased
- 2 boolean No FALSE This determines whether or not Capital letters within words should be lowercased, e.g. \"aAa\" to \"Aaa\"
+## Basic usage
+```smarty
+{$myVar|capitalize}
+```
+## Parameters
- <?php
+| Parameter | Type | Required | Description |
+|-----------|---------|----------|-------------------------------------------------------------------------------------------------------|
+| 1 | boolean | No | This determines whether or not words with digits will be uppercased |
+| 2 | boolean | No | This determines whether or not Capital letters within words should be lowercased, e.g. "aAa" to "Aaa" |
- $smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
- ?>
+## Examples
+
+```php
+<?php
+
+ $smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
+```
Where the template is:
-
+```smarty
{$articleTitle}
{$articleTitle|capitalize}
{$articleTitle|capitalize:true}
-
+```
Will output:
-
+```
next x-men film, x3, delayed.
Next X-Men Film, x3, Delayed.
Next X-Men Film, X3, Delayed.
-
+```
-See also [`lower`](#language.modifier.lower) and
-[`upper`](#language.modifier.upper)
+See also [`lower`](language-modifier-lower.md) and
+[`upper`](language-modifier-upper.md)
diff --git a/docs/designers/language-modifiers/language-modifier-cat.md b/docs/designers/language-modifiers/language-modifier-cat.md
index 1f43ae17..97dda4b3 100644
--- a/docs/designers/language-modifiers/language-modifier-cat.md
+++ b/docs/designers/language-modifiers/language-modifier-cat.md
@@ -1,31 +1,36 @@
-cat {#language.modifier.cat}
-===
+# cat
This value is concatenated to the given variable.
- Parameter Position Type Required Default Description
- -------------------- -------- ---------- --------- -----------------------------------------------
- 1 string No *empty* This value to catenate to the given variable.
+## Basic usage
+```smarty
+{$myVar|cat:' units'}
+```
+## Parameters
- <?php
+| Parameter | Type | Required | Description |
+|-----------|--------|----------|--------------------------------------------------|
+| 1 | string | No | This value to concatenate to the given variable. |
- $smarty->assign('articleTitle', "Psychics predict world didn't end");
+## Examples
- ?>
+```php
+<?php
-
+ $smarty->assign('articleTitle', "Psychics predict world didn't end");
-Where template is:
+```
+Where template is:
+```smarty
{$articleTitle|cat:' yesterday.'}
-
-
+```
Will output:
-
+```
Psychics predict world didn't end yesterday.
-
+```
diff --git a/docs/designers/language-modifiers/language-modifier-count-characters.md b/docs/designers/language-modifiers/language-modifier-count-characters.md
index 23bc00d5..8fc37d7a 100644
--- a/docs/designers/language-modifiers/language-modifier-count-characters.md
+++ b/docs/designers/language-modifiers/language-modifier-count-characters.md
@@ -1,39 +1,43 @@
-count\_characters {#language.modifier.count.characters}
-=================
+# count_characters
This is used to count the number of characters in a variable.
- Parameter Position Type Required Default Description
- -------------------- --------- ---------- --------- -------------------------------------------------------------------------------
- 1 boolean No FALSE This determines whether or not to include whitespace characters in the count.
+## Basic usage
+```smarty
+{$myVar|count_characters}
+```
+## Parameters
- <?php
+| Parameter | Type | Required | Description |
+|-----------|---------|----------|------------------------------------------------------------------------|
+| 1 | boolean | No | This determines whether to include whitespace characters in the count. |
- $smarty->assign('articleTitle', 'Cold Wave Linked to Temperatures.');
+## Examples
- ?>
+```php
+<?php
-
+ $smarty->assign('articleTitle', 'Cold Wave Linked to Temperatures.');
-Where template is:
+```
+Where template is:
+```smarty
{$articleTitle}
{$articleTitle|count_characters}
{$articleTitle|count_characters:true}
-
-
+```
Will output:
-
+```
Cold Wave Linked to Temperatures.
29
33
-
+```
-
-See also [`count_words`](#language.modifier.count.words),
-[`count_sentences`](#language.modifier.count.sentences) and
-[`count_paragraphs`](#language.modifier.count.paragraphs).
+See also [`count_words`](language-modifier-count-words.md),
+[`count_sentences`](language-modifier-count-sentences.md) and
+[`count_paragraphs`](language-modifier-count-paragraphs.md).
diff --git a/docs/designers/language-modifiers/language-modifier-count-paragraphs.md b/docs/designers/language-modifiers/language-modifier-count-paragraphs.md
index 02c474e6..060cb98a 100644
--- a/docs/designers/language-modifiers/language-modifier-count-paragraphs.md
+++ b/docs/designers/language-modifiers/language-modifier-count-paragraphs.md
@@ -1,38 +1,41 @@
-count\_paragraphs {#language.modifier.count.paragraphs}
-=================
+# count_paragraphs
This is used to count the number of paragraphs in a variable.
+## Basic usage
+```smarty
+{$myVar|count_paragraphs}
+```
- <?php
+## Examples
+
+```php
+<?php
$smarty->assign('articleTitle',
"War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.\n\n
Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation."
);
- ?>
-
-
+```
Where template is:
-
+```smarty
{$articleTitle}
{$articleTitle|count_paragraphs}
-
+```
Will output:
-
+```
War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.
Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
2
+```
-
-
-See also [`count_characters`](#language.modifier.count.characters),
-[`count_sentences`](#language.modifier.count.sentences) and
-[`count_words`](#language.modifier.count.words).
+See also [`count_characters`](language-modifier-count-characters.md),
+[`count_sentences`](language-modifier-count-sentences.md) and
+[`count_words`](language-modifier-count-words.md).
diff --git a/docs/designers/language-modifiers/language-modifier-count-sentences.md b/docs/designers/language-modifiers/language-modifier-count-sentences.md
index 0a77ab82..dd2f69c6 100644
--- a/docs/designers/language-modifiers/language-modifier-count-sentences.md
+++ b/docs/designers/language-modifiers/language-modifier-count-sentences.md
@@ -1,37 +1,39 @@
-count\_sentences {#language.modifier.count.sentences}
-================
+# count_sentences
This is used to count the number of sentences in a variable. A sentence
being delimited by a dot, question- or exclamation-mark (.?!).
+## Basic usage
+```smarty
+{$myVar|count_sentences}
+```
- <?php
+## Examples
+
+```php
+<?php
$smarty->assign('articleTitle',
'Two Soviet Ships Collide - One Dies.
Enraged Cow Injures Farmer with Axe.'
);
- ?>
-
-
+```
Where template is:
-
+```smarty
{$articleTitle}
{$articleTitle|count_sentences}
-
-
+```
Will output:
-
+```
Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
2
-
+```
-
-See also [`count_characters`](#language.modifier.count.characters),
-[`count_paragraphs`](#language.modifier.count.paragraphs) and
-[`count_words`](#language.modifier.count.words).
+See also [`count_characters`](language-modifier-count-characters.md),
+[`count_paragraphs`](language-modifier-count-paragraphs.md) and
+[`count_words`](language-modifier-count-words.md).
diff --git a/docs/designers/language-modifiers/language-modifier-count-words.md b/docs/designers/language-modifiers/language-modifier-count-words.md
index d25fbd5b..1ab0d1d4 100644
--- a/docs/designers/language-modifiers/language-modifier-count-words.md
+++ b/docs/designers/language-modifiers/language-modifier-count-words.md
@@ -1,33 +1,35 @@
-count\_words {#language.modifier.count.words}
-============
+# count_words
This is used to count the number of words in a variable.
+## Basic usage
+```smarty
+{$myVar|count_words}
+```
- <?php
+## Examples
- $smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
+```php
+<?php
- ?>
+ $smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
-
+```
Where template is:
-
+```smarty
{$articleTitle}
{$articleTitle|count_words}
-
-
+```
This will output:
-
+```
Dealers Will Hear Car Talk at Noon.
7
+```
-
-
-See also [`count_characters`](#language.modifier.count.characters),
-[`count_paragraphs`](#language.modifier.count.paragraphs) and
-[`count_sentences`](#language.modifier.count.sentences).
+See also [`count_characters`](language-modifier-count-characters.md),
+[`count_paragraphs`](language-modifier-count-paragraphs.md) and
+[`count_sentences`](language-modifier-count-sentences.md).
diff --git a/docs/designers/language-modifiers/language-modifier-date-format.md b/docs/designers/language-modifiers/language-modifier-date-format.md
index 6fd96b36..620d085b 100644
--- a/docs/designers/language-modifiers/language-modifier-date-format.md
+++ b/docs/designers/language-modifiers/language-modifier-date-format.md
@@ -1,5 +1,4 @@
-date\_format {#language.modifier.date.format}
-============
+# date_format
This formats a date and time into the given
[`strftime()`](https://www.php.net/strftime) format. Dates can be passed to
@@ -11,10 +10,17 @@ made up of month day year, parsable by php\'s
the date passed to `date_format` is empty and a second parameter is
passed, that will be used as the date to format.
- Parameter Position Type Required Default Description
- -------------------- -------- ---------- ------------ -------------------------------------------------
- 1 string No \%b %e, %Y This is the format for the outputted date.
- 2 string No n/a This is the default date if the input is empty.
+## Basic usage
+```smarty
+{$myVar|date_format:"%Y-%m-%d"}
+```
+
+## Parameters
+
+| Parameter Position | Type | Required | Default | Description |
+|--------------------|--------|----------|-----------|-------------------------------------------------|
+| 1 | string | No | %b %e, %Y | This is the format for the outputted date. |
+| 2 | string | No | n/a | This is the default date if the input is empty. |
> **Note**
>
@@ -33,143 +39,107 @@ passed, that will be used as the date to format.
> **Note**
>
-> `date_format` is essentially a wrapper to PHP\'s
+> `date_format` is essentially a wrapper to PHP's
> [`strftime()`](https://www.php.net/strftime) function. You may have more
-> or less conversion specifiers available depending on your system\'s
+> or less conversion specifiers available depending on your system's
> [`strftime()`](https://www.php.net/strftime) function where PHP was
> compiled. Check your system\'s manpage for a full list of valid
> specifiers. However, a few of the specifiers are emulated on Windows.
> These are: %D, %e, %h, %l, %n, %r, %R, %t, %T.
+## Examples
- <?php
-
- $config['date'] = '%I:%M %p';
- $config['time'] = '%H:%M:%S';
- $smarty->assign('config', $config);
- $smarty->assign('yesterday', strtotime('-1 day'));
+```php
+<?php
- ?>
+$config['date'] = '%I:%M %p';
+$config['time'] = '%H:%M:%S';
+$smarty->assign('config', $config);
+$smarty->assign('yesterday', strtotime('-1 day'));
-
+```
-This template uses [`$smarty.now`](#language.variables.smarty.now) to
+This template uses [`$smarty.now`](../language-variables/language-variables-smarty.md#smartynow-languagevariablessmartynow) to
get the current time:
-
- {$smarty.now|date_format}
- {$smarty.now|date_format:"%D"}
- {$smarty.now|date_format:$config.date}
- {$yesterday|date_format}
- {$yesterday|date_format:"%A, %B %e, %Y"}
- {$yesterday|date_format:$config.time}
-
-
+```smarty
+{$smarty.now|date_format}
+{$smarty.now|date_format:"%D"}
+{$smarty.now|date_format:$config.date}
+{$yesterday|date_format}
+{$yesterday|date_format:"%A, %B %e, %Y"}
+{$yesterday|date_format:$config.time}
+```
This above will output:
-
- Jan 1, 2022
- 01/01/22
- 02:33 pm
- Dec 31, 2021
- Monday, December 1, 2021
- 14:33:00
-
+```
+Jan 1, 2022
+01/01/22
+02:33 pm
+Dec 31, 2021
+Monday, December 1, 2021
+14:33:00
+```
+## Conversion specifiers
`date_format` conversion specifiers:
-- \%a - abbreviated weekday name according to the current locale
-
-- \%A - full weekday name according to the current locale
-
-- \%b - abbreviated month name according to the current locale
-
-- \%B - full month name according to the current locale
-
-- \%c - preferred date and time representation for the current locale
-
-- \%C - century number (the year divided by 100 and truncated to an
+- %a - abbreviated weekday name according to the current locale
+- %A - full weekday name according to the current locale
+- %b - abbreviated month name according to the current locale
+- %B - full month name according to the current locale
+- %c - preferred date and time representation for the current locale
+- %C - century number (the year divided by 100 and truncated to an
integer, range 00 to 99)
-
-- \%d - day of the month as a decimal number (range 01 to 31)
-
-- \%D - same as %m/%d/%y
-
-- \%e - day of the month as a decimal number, a single digit is
+- %d - day of the month as a decimal number (range 01 to 31)
+- %D - same as %m/%d/%y
+- %e - day of the month as a decimal number, a single digit is
preceded by a space (range 1 to 31)
-
-- \%g - Week-based year within century \[00,99\]
-
-- \%G - Week-based year, including the century \[0000,9999\]
-
-- \%h - same as %b
-
-- \%H - hour as a decimal number using a 24-hour clock (range 00
+- %g - Week-based year within century \[00,99\]
+- %G - Week-based year, including the century \[0000,9999\]
+- %h - same as %b
+- %H - hour as a decimal number using a 24-hour clock (range 00
to 23)
-
-- \%I - hour as a decimal number using a 12-hour clock (range 01
+- %I - hour as a decimal number using a 12-hour clock (range 01
to 12)
-
-- \%j - day of the year as a decimal number (range 001 to 366)
-
-- \%k - Hour (24-hour clock) single digits are preceded by a blank.
+- %j - day of the year as a decimal number (range 001 to 366)
+- %k - Hour (24-hour clock) single digits are preceded by a blank.
(range 0 to 23)
-
-- \%l - hour as a decimal number using a 12-hour clock, single digits
+- %l - hour as a decimal number using a 12-hour clock, single digits
preceded by a space (range 1 to 12)
-
-- \%m - month as a decimal number (range 01 to 12)
-
-- \%M - minute as a decimal number
-
-- \%n - newline character
-
-- \%p - either \`am\' or \`pm\' according to the given time value, or
+- %m - month as a decimal number (range 01 to 12)
+- %M - minute as a decimal number
+- %n - newline character
+- %p - either 'am' or 'pm' according to the given time value, or
the corresponding strings for the current locale
-
-- \%r - time in a.m. and p.m. notation
-
-- \%R - time in 24 hour notation
-
-- \%S - second as a decimal number
-
-- \%t - tab character
-
-- \%T - current time, equal to %H:%M:%S
-
-- \%u - weekday as a decimal number \[1,7\], with 1 representing
+- %r - time in a.m. and p.m. notation
+- %R - time in 24 hour notation
+- %S - second as a decimal number
+- %t - tab character
+- %T - current time, equal to %H:%M:%S
+- %u - weekday as a decimal number \[1,7\], with 1 representing
Monday
-
-- \%U - week number of the current year as a decimal number, starting
+- %U - week number of the current year as a decimal number, starting
with the first Sunday as the first day of the first week
-
-- \%V - The ISO 8601:1988 week number of the current year as a decimal
+- %V - The ISO 8601:1988 week number of the current year as a decimal
number, range 01 to 53, where week 1 is the first week that has at
least 4 days in the current year, and with Monday as the first day
of the week.
-
-- \%w - day of the week as a decimal, Sunday being 0
-
-- \%W - week number of the current year as a decimal number, starting
+- %w - day of the week as a decimal, Sunday being 0
+- %W - week number of the current year as a decimal number, starting
with the first Monday as the first day of the first week
-
-- \%x - preferred date representation for the current locale without
+- %x - preferred date representation for the current locale without
the time
-
-- \%X - preferred time representation for the current locale without
+- %X - preferred time representation for the current locale without
the date
+- %y - year as a decimal number without a century (range 00 to 99)
+- %Y - year as a decimal number including the century
+- %Z - time zone or name or abbreviation
+- %% - a literal '%' character
-- \%y - year as a decimal number without a century (range 00 to 99)
-
-- \%Y - year as a decimal number including the century
-
-- \%Z - time zone or name or abbreviation
-
-- \%% - a literal \`%\' character
-
-See also [`$smarty.now`](#language.variables.smarty.now),
+See also [`$smarty.now`](../language-variables/language-variables-smarty.md#smartynow-languagevariablessmartynow),
[`strftime()`](https://www.php.net/strftime),
-[`{html_select_date}`](#language.function.html.select.date) and the
-[date tips](#tips.dates) page.
+[`{html_select_date}`](../language-custom-functions/language-function-html-select-date.md) and the
+[date tips](../../appendixes/tips.md#dates) page.
diff --git a/docs/designers/language-modifiers/language-modifier-default.md b/docs/designers/language-modifiers/language-modifier-default.md
index ce08e96e..b8697a0d 100644
--- a/docs/designers/language-modifiers/language-modifier-default.md
+++ b/docs/designers/language-modifiers/language-modifier-default.md
@@ -1,41 +1,45 @@
-default {#language.modifier.default}
-=======
+# default
This is used to set a default value for a variable. If the variable is
unset or an empty string, the given default value is printed instead.
Default takes the one argument.
- Parameter Position Type Required Default Description
- -------------------- -------- ---------- --------- ---------------------------------------------------------------
- 1 string No *empty* This is the default value to output if the variable is empty.
+## Basic usage
+```smarty
+{$myVar|default:"(none)"}
+```
+## Parameters
- <?php
+| Parameter | Type | Required | Default | Description |
+|-----------|--------|----------|---------|---------------------------------------------------------------|
+| 1 | string | No | *empty* | This is the default value to output if the variable is empty. |
+
+## Examples
+
+```php
+<?php
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
$smarty->assign('email', '');
- ?>
-
-
+```
Where template is:
-
- {$articleTitle|default:'no title'}
- {$myTitle|default:'no title'}
- {$email|default:'No email address available'}
-
-
+```smarty
+{$articleTitle|default:'no title'}
+{$myTitle|default:'no title'}
+{$email|default:'No email address available'}
+```
Will output:
+```
+Dealers Will Hear Car Talk at Noon.
+no title
+No email address available
+```
- Dealers Will Hear Car Talk at Noon.
- no title
- No email address available
-
-
-
-See also the [default variable handling](#tips.default.var.handling) and
-the [blank variable handling](#tips.blank.var.handling) pages.
+See also the [default variable handling](../../appendixes/tips.md#default-variable-handling) and
+the [blank variable handling](../../appendixes/tips.md#blank-variable-handling) pages.
diff --git a/docs/designers/language-modifiers/language-modifier-escape.md b/docs/designers/language-modifiers/language-modifier-escape.md
index 27d711f3..6fd5dd2b 100644
--- a/docs/designers/language-modifiers/language-modifier-escape.md
+++ b/docs/designers/language-modifiers/language-modifier-escape.md
@@ -1,74 +1,78 @@
-escape {#language.modifier.escape}
-======
+# escape
`escape` is used to encode or escape a variable to `html`, `url`,
`single quotes`, `hex`, `hexentity`, `javascript` and `mail`. By default
its `html`.
- Parameter Position Type Required Possible Values Default Description
- -------------------- --------- ---------- ------------------------------------------------------------------------------------------------------------ --------- -------------------------------------------------------------------------------------
- 1 string No `html`, `htmlall`, `url`, `urlpathinfo`, `quotes`, `hex`, `hexentity`, `javascript`, `mail` `html` This is the escape format to use.
- 2 string No `ISO-8859-1`, `UTF-8`, and any character set supported by [`htmlentities()`](https://www.php.net/htmlentities) `UTF-8` The character set encoding passed to htmlentities() et. al.
- 3 boolean No FALSE TRUE Double encode entites from &amp; to &amp;amp; (applys to `html` and `htmlall` only)
+## Basic usage
+```smarty
+{$myVar|escape}
+```
+## Parameters
- <?php
+| Parameter Position | Type | Required | Possible Values | Default | Description |
+|--------------------|---------|----------|----------------------------------------------------------------------------------------------------------------|---------|--------------------------------------------------------------------------------------|
+| 1 | string | No | `html`, `htmlall`, `url`, `urlpathinfo`, `quotes`, `hex`, `hexentity`, `javascript`, `mail` | `html` | This is the escape format to use. |
+| 2 | string | No | `ISO-8859-1`, `UTF-8`, and any character set supported by [`htmlentities()`](https://www.php.net/htmlentities) | `UTF-8` | The character set encoding passed to htmlentities() et. al. |
+| 3 | boolean | No | FALSE | TRUE | Double encode entities from &amp; to &amp;amp; (applies to `html` and `htmlall` only) |
- $smarty->assign('articleTitle',
- "'Stiff Opposition Expected to Casketless Funeral Plan'"
- );
- $smarty->assign('EmailAddress','smarty@example.com');
- ?>
+## Examples
-
-
-These are example `escape` template lines followed by the output
+```php
+<?php
+$smarty->assign('articleTitle',
+ "'Stiff Opposition Expected to Casketless Funeral Plan'"
+ );
+$smarty->assign('EmailAddress','smarty@example.com');
- {$articleTitle}
- 'Stiff Opposition Expected to Casketless Funeral Plan'
+```
+
- {$articleTitle|escape}
- &#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
+These are example `escape` template lines followed by the output
- {$articleTitle|escape:'html'} {* escapes & " ' < > *}
- &#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
+```smarty
+{$articleTitle}
+'Stiff Opposition Expected to Casketless Funeral Plan'
- {$articleTitle|escape:'htmlall'} {* escapes ALL html entities *}
- &#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
+{$articleTitle|escape}
+&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
- <a href="?title={$articleTitle|escape:'url'}">click here</a>
- <a
- href="?title=%27Stiff%20Opposition%20Expected%20to%20Casketless%20Funeral%20Plan%27">click here</a>
+{$articleTitle|escape:'html'} {* escapes & " ' < > *}
+&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
- {$articleTitle|escape:'quotes'}
- \'Stiff Opposition Expected to Casketless Funeral Plan\'
+{$articleTitle|escape:'htmlall'} {* escapes ALL html entities *}
+&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
- <a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
- {$EmailAddress|escape:'mail'} {* this converts to email to text *}
- <a href="mailto:%62%6f%..snip..%65%74">&#x62;&#x6f;&#x62..snip..&#x65;&#x74;</a>
+<a href="?title={$articleTitle|escape:'url'}">click here</a>
+<a
+href="?title=%27Stiff%20Opposition%20Expected%20to%20Casketless%20Funeral%20Plan%27">click here</a>
- {'mail@example.com'|escape:'mail'}
- smarty [AT] example [DOT] com
+{$articleTitle|escape:'quotes'}
+\'Stiff Opposition Expected to Casketless Funeral Plan\'
-
+<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
+{$EmailAddress|escape:'mail'} {* this converts to email to text *}
+<a href="mailto:%62%6f%..snip..%65%74">&#x62;&#x6f;&#x62..snip..&#x65;&#x74;</a>
+{'mail@example.com'|escape:'mail'}
+smarty [AT] example [DOT] com
- {* the "rewind" parameter registers the current location *}
- <a href="$my_path?page=foo&rewind=$my_uri|urlencode}">click here</a>
+{* the "rewind" parameter registers the current location *}
+<a href="$my_path?page=foo&rewind={$my_uri|escape:url}">click here</a>
-
+```
This snippet is useful for emails, but see also
-[`{mailto}`](#language.function.mailto)
-
+[`{mailto}`](../language-custom-functions/language-function-mailto.md)
- {* email address mangled *}
- <a href="mailto:{$EmailAddress|escape:'hex'}">{$EmailAddress|escape:'mail'}</a>
-
-
+```smarty
+{* email address mangled *}
+<a href="mailto:{$EmailAddress|escape:'hex'}">{$EmailAddress|escape:'mail'}</a>
+```
-See also [escaping smarty parsing](#language.escaping),
-[`{mailto}`](#language.function.mailto) and the [obfuscating email
-addresses](#tips.obfuscating.email) page.
+See also [escaping smarty parsing](../language-basic-syntax/language-escaping.md),
+[`{mailto}`](../language-custom-functions/language-function-mailto.md) and the [obfuscating email
+addresses](../../appendixes/tips.md#obfuscating-e-mail-addresses) page.
diff --git a/docs/designers/language-modifiers/language-modifier-from-charset.md b/docs/designers/language-modifiers/language-modifier-from-charset.md
index d6c01f99..bf4b4769 100644
--- a/docs/designers/language-modifiers/language-modifier-from-charset.md
+++ b/docs/designers/language-modifiers/language-modifier-from-charset.md
@@ -1,13 +1,14 @@
-from\_charset {#language.modifier.from_charset}
-=============
+# from_charset
`from_charset` is used to transcode a string from a given charset to the
-internal charset. This is the exact opposite of the [to\_charset
-modifier](#language.modifier.to_charset).
+internal charset. This is the exact opposite of the [to_charset
+modifier](language-modifier-to-charset.md).
- Parameter Position Type Required Possible Values Default Description
- -------------------- -------- ---------- -------------------------------------------------------------------------------------------------------------------------- -------------- ---------------------------------------------------------------
- 1 string No `ISO-8859-1`, `UTF-8`, and any character set supported by [`mb_convert_encoding()`](https://www.php.net/mb_convert_encoding) `ISO-8859-1` The charset encoding the value is supposed to be decoded from
+## Parameters
+
+| Parameter Position | Type | Required | Possible Values | Default | Description |
+|--------------------|--------|----------|------------------------------------------------------------------------------------------------------------------------------|--------------|---------------------------------------------------------------|
+| 1 | string | No | `ISO-8859-1`, `UTF-8`, and any character set supported by [`mb_convert_encoding()`](https://www.php.net/mb_convert_encoding) | `ISO-8859-1` | The charset encoding the value is supposed to be decoded from |
> **Note**
>
@@ -15,5 +16,5 @@ modifier](#language.modifier.to_charset).
> modifier should only be used in cases where the application cannot
> anticipate that a certain string is required in another encoding.
-See also [Charset Encoding](#charset), [from\_charset
-modifier](#language.modifier.from_charset).
+See also [Charset Encoding](../../programmers/charset.md), [to_charset
+modifier](language-modifier-to-charset.md).
diff --git a/docs/designers/language-modifiers/language-modifier-indent.md b/docs/designers/language-modifiers/language-modifier-indent.md
index d0264dca..9fa3540a 100644
--- a/docs/designers/language-modifiers/language-modifier-indent.md
+++ b/docs/designers/language-modifiers/language-modifier-indent.md
@@ -1,62 +1,67 @@
-indent {#language.modifier.indent}
-======
+# indent
This indents a string on each line, default is 4. As an optional
parameter, you can specify the number of characters to indent. As an
optional second parameter, you can specify the character to use to
-indent with eg use `"\t"` for a tab.
+indent with. For example: use `"\t"` for a tab.
- Parameter Position Type Required Default Description
- -------------------- --------- ---------- ------------- ---------------------------------------------------
- 1 integer No 4 This determines how many characters to indent to.
- 2 string No (one space) This is the character used to indent with.
+## Basic usage
+```smarty
+{$myVar|indent:4}
+```
+## Parameters
- <?php
+| Parameter Position | Type | Required | Default | Description |
+|--------------------|---------|----------|-------------|---------------------------------------------------|
+| 1 | integer | No | 4 | This determines how many characters to indent to. |
+| 2 | string | No | (one space) | This is the character used to indent with. |
- $smarty->assign('articleTitle',
- 'NJ judge to rule on nude beach.
- Sun or rain expected today, dark tonight.
- Statistics show that teen pregnancy drops off significantly after 25.'
- );
- ?>
+## Examples
-
+```php
+<?php
-Where template is:
+$smarty->assign('articleTitle',
+ 'NJ judge to rule on nude beach.
+Sun or rain expected today, dark tonight.
+Statistics show that teen pregnancy drops off significantly after 25.'
+ );
+```
+Where template is:
- {$articleTitle}
-
- {$articleTitle|indent}
+```smarty
+{$articleTitle}
- {$articleTitle|indent:10}
+{$articleTitle|indent}
- {$articleTitle|indent:1:"\t"}
+{$articleTitle|indent:10}
+{$articleTitle|indent:1:"\t"}
+```
-
Will output:
+```
+NJ judge to rule on nude beach.
+Sun or rain expected today, dark tonight.
+Statistics show that teen pregnancy drops off significantly after 25.
NJ judge to rule on nude beach.
Sun or rain expected today, dark tonight.
Statistics show that teen pregnancy drops off significantly after 25.
+ NJ judge to rule on nude beach.
+ Sun or rain expected today, dark tonight.
+ Statistics show that teen pregnancy drops off significantly after 25.
+
NJ judge to rule on nude beach.
Sun or rain expected today, dark tonight.
Statistics show that teen pregnancy drops off significantly after 25.
-
- NJ judge to rule on nude beach.
- Sun or rain expected today, dark tonight.
- Statistics show that teen pregnancy drops off significantly after 25.
-
- NJ judge to rule on nude beach.
- Sun or rain expected today, dark tonight.
- Statistics show that teen pregnancy drops off significantly after 25.
-
+```
-See also [`strip`](#language.modifier.strip),
-[`wordwrap`](#language.modifier.wordwrap) and
-[`spacify`](#language.modifier.spacify).
+See also [`strip`](language-modifier-strip.md),
+[`wordwrap`](language-modifier-wordwrap.md) and
+[`spacify`](language-modifier-spacify.md).
diff --git a/docs/designers/language-modifiers/language-modifier-lower.md b/docs/designers/language-modifiers/language-modifier-lower.md
index b8b5a2c0..e5e6886f 100644
--- a/docs/designers/language-modifiers/language-modifier-lower.md
+++ b/docs/designers/language-modifiers/language-modifier-lower.md
@@ -1,33 +1,34 @@
-lower {#language.modifier.lower}
-=====
+# lower
This is used to lowercase a variable. This is equivalent to the PHP
[`strtolower()`](https://www.php.net/strtolower) function.
+## Basic usage
+```smarty
+{$myVar|lower}
+```
- <?php
+## Examples
- $smarty->assign('articleTitle', 'Two Convicts Evade Noose, Jury Hung.');
+```php
+<?php
- ?>
-
-
+$smarty->assign('articleTitle', 'Two Convicts Evade Noose, Jury Hung.');
+```
Where template is:
-
- {$articleTitle}
- {$articleTitle|lower}
-
-
+```smarty
+{$articleTitle}
+{$articleTitle|lower}
+```
This will output:
-
- Two Convicts Evade Noose, Jury Hung.
- two convicts evade noose, jury hung.
-
+```
+Two Convicts Evade Noose, Jury Hung.
+two convicts evade noose, jury hung.
+```
-
-See also [`upper`](#language.modifier.upper) and
-[`capitalize`](#language.modifier.capitalize).
+See also [`upper`](language-modifier-upper.md) and
+[`capitalize`](language-modifier-capitalize.md).
diff --git a/docs/designers/language-modifiers/language-modifier-nl2br.md b/docs/designers/language-modifiers/language-modifier-nl2br.md
index 9e0aac6d..2808716f 100644
--- a/docs/designers/language-modifiers/language-modifier-nl2br.md
+++ b/docs/designers/language-modifiers/language-modifier-nl2br.md
@@ -1,35 +1,37 @@
-nl2br {#language.modifier.nl2br}
-=====
+# nl2br
All `"\n"` line breaks will be converted to html `<br />` tags in the
given variable. This is equivalent to the PHP\'s
[`nl2br()`](https://www.php.net/nl2br) function.
+## Basic usage
+```smarty
+{$myVar|nl2br}
+```
- <?php
+## Examples
- $smarty->assign('articleTitle',
- "Sun or rain expected\ntoday, dark tonight"
- );
+```php
+<?php
- ?>
+$smarty->assign('articleTitle',
+ "Sun or rain expected\ntoday, dark tonight"
+ );
-
+```
Where the template is:
-
- {$articleTitle|nl2br}
-
+```smarty
+{$articleTitle|nl2br}
+```
-
Will output:
+```
+Sun or rain expected<br />today, dark tonight
+```
- Sun or rain expected<br />today, dark tonight
-
-
-
-See also [`word_wrap`](#language.modifier.wordwrap),
-[`count_paragraphs`](#language.modifier.count.paragraphs) and
-[`count_sentences`](#language.modifier.count.sentences).
+See also [`word_wrap`](language-modifier-wordwrap.md),
+[`count_paragraphs`](language-modifier-count-paragraphs.md) and
+[`count_sentences`](language-modifier-count-sentences.md).
diff --git a/docs/designers/language-modifiers/language-modifier-regex-replace.md b/docs/designers/language-modifiers/language-modifier-regex-replace.md
index acc0008a..033d2a43 100644
--- a/docs/designers/language-modifiers/language-modifier-regex-replace.md
+++ b/docs/designers/language-modifiers/language-modifier-regex-replace.md
@@ -1,10 +1,14 @@
-regex\_replace {#language.modifier.regex.replace}
-==============
+# regex_replace
A regular expression search and replace on a variable. Use the
[`preg_replace()`](https://www.php.net/preg_replace) syntax from the PHP
manual.
+## Basic usage
+```smarty
+{$myVar|regex_replace:"/foo/":"bar"}
+```
+
> **Note**
>
> Although Smarty supplies this regex convenience modifier, it is
@@ -12,40 +16,40 @@ manual.
> functions or modifiers. Regular expressions are considered application
> code and are not part of presentation logic.
-Parameters
+## Parameters
- Parameter Position Type Required Default Description
- -------------------- -------- ---------- --------- ------------------------------------------------
- 1 string Yes *n/a* This is the regular expression to be replaced.
- 2 string Yes *n/a* This is the string of text to replace with.
+| Parameter Position | Type | Required | Description |
+|--------------------|--------|----------|------------------------------------------------|
+| 1 | string | Yes | This is the regular expression to be replaced. |
+| 2 | string | Yes | This is the string of text to replace with. |
- <?php
+## Examples
- $smarty->assign('articleTitle', "Infertility unlikely to\nbe passed on, experts say.");
+```php
+<?php
- ?>
+$smarty->assign('articleTitle', "Infertility unlikely to\nbe passed on, experts say.");
-
+```
Where template is:
+```smarty
+{* replace each carriage return, tab and new line with a space *}
- {* replace each carriage return, tab and new line with a space *}
-
- {$articleTitle}
- {$articleTitle|regex_replace:"/[\r\t\n]/":" "}
-
+{$articleTitle}
+{$articleTitle|regex_replace:"/[\r\t\n]/":" "}
+```
-
Will output:
-
- Infertility unlikely to
- be passed on, experts say.
- Infertility unlikely to be passed on, experts say.
-
+```
+Infertility unlikely to
+be passed on, experts say.
+Infertility unlikely to be passed on, experts say.
+```
-See also [`replace`](#language.modifier.replace) and
-[`escape`](#language.modifier.escape).
+See also [`replace`](language-modifier-replace.md) and
+[`escape`](language-modifier-escape.md).
diff --git a/docs/designers/language-modifiers/language-modifier-replace.md b/docs/designers/language-modifiers/language-modifier-replace.md
index cdff14fb..0e01ab46 100644
--- a/docs/designers/language-modifiers/language-modifier-replace.md
+++ b/docs/designers/language-modifiers/language-modifier-replace.md
@@ -1,40 +1,45 @@
-replace {#language.modifier.replace}
-=======
+# replace
A simple search and replace on a variable. This is equivalent to the
-PHP\'s [`str_replace()`](https://www.php.net/str_replace) function.
+PHP's [`str_replace()`](https://www.php.net/str_replace) function.
- Parameter Position Type Required Default Description
- -------------------- -------- ---------- --------- ---------------------------------------------
- 1 string Yes *n/a* This is the string of text to be replaced.
- 2 string Yes *n/a* This is the string of text to replace with.
+## Basic usage
+```smarty
+{$myVar|replace:"foo":"bar"}
+```
+## Parameters
- <?php
+| Parameter Position | Type | Required | Description |
+|--------------------|--------|----------|---------------------------------------------|
+| 1 | string | Yes | This is the string of text to be replaced. |
+| 2 | string | Yes | This is the string of text to replace with. |
- $smarty->assign('articleTitle', "Child's Stool Great for Use in Garden.");
- ?>
+## Examples
-
+```php
+<?php
-Where template is:
+$smarty->assign('articleTitle', "Child's Stool Great for Use in Garden.");
+```
- {$articleTitle}
- {$articleTitle|replace:'Garden':'Vineyard'}
- {$articleTitle|replace:' ':' '}
+Where template is:
+```smarty
+{$articleTitle}
+{$articleTitle|replace:'Garden':'Vineyard'}
+{$articleTitle|replace:' ':' '}
+```
-
Will output:
+```
+Child's Stool Great for Use in Garden.
+Child's Stool Great for Use in Vineyard.
+Child's Stool Great for Use in Garden.
+```
- Child's Stool Great for Use in Garden.
- Child's Stool Great for Use in Vineyard.
- Child's Stool Great for Use in Garden.
-
-
-
-See also [`regex_replace`](#language.modifier.regex.replace) and
-[`escape`](#language.modifier.escape).
+See also [`regex_replace`](language-modifier-regex-replace.md) and
+[`escape`](language-modifier-escape.md).
diff --git a/docs/designers/language-modifiers/language-modifier-spacify.md b/docs/designers/language-modifiers/language-modifier-spacify.md
index 8856dab4..229e2d22 100644
--- a/docs/designers/language-modifiers/language-modifier-spacify.md
+++ b/docs/designers/language-modifiers/language-modifier-spacify.md
@@ -1,40 +1,44 @@
-spacify {#language.modifier.spacify}
-=======
+# spacify
`spacify` is a way to insert a space between every character of a
variable. You can optionally pass a different character or string to
insert.
- Parameter Position Type Required Default Description
- -------------------- -------- ---------- ------------- -----------------------------------------------------------------
- 1 string No *one space* This what gets inserted between each character of the variable.
+## Basic usage
+```smarty
+{$myVar|spacify}
+```
+## Parameters
- <?php
+| Parameter Position | Type | Required | Default | Description |
+|--------------------|--------|----------|-------------|-----------------------------------------------------------------|
+| 1 | string | No | *one space* | This what gets inserted between each character of the variable. |
- $smarty->assign('articleTitle', 'Something Went Wrong in Jet Crash, Experts Say.');
+## Examples
- ?>
+```php
+<?php
-
-
-Where template is:
+$smarty->assign('articleTitle', 'Something Went Wrong in Jet Crash, Experts Say.');
+```
- {$articleTitle}
- {$articleTitle|spacify}
- {$articleTitle|spacify:"^^"}
+Where template is:
-
+```smarty
+{$articleTitle}
+{$articleTitle|spacify}
+{$articleTitle|spacify:"^^"}
+```
Will output:
+```
+Something Went Wrong in Jet Crash, Experts Say.
+S o m e t h i n g W .... snip .... s h , E x p e r t s S a y .
+S^^o^^m^^e^^t^^h^^i^^n^^g^^ .... snip .... ^^e^^r^^t^^s^^ ^^S^^a^^y^^.
+```
- Something Went Wrong in Jet Crash, Experts Say.
- S o m e t h i n g W .... snip .... s h , E x p e r t s S a y .
- S^^o^^m^^e^^t^^h^^i^^n^^g^^ .... snip .... ^^e^^r^^t^^s^^ ^^S^^a^^y^^.
-
-
-
-See also [`wordwrap`](#language.modifier.wordwrap) and
-[`nl2br`](#language.modifier.nl2br).
+See also [`wordwrap`](language-modifier-wordwrap.md) and
+[`nl2br`](language-modifier-nl2br.md).
diff --git a/docs/designers/language-modifiers/language-modifier-string-format.md b/docs/designers/language-modifiers/language-modifier-string-format.md
index 70a77966..6163a078 100644
--- a/docs/designers/language-modifiers/language-modifier-string-format.md
+++ b/docs/designers/language-modifiers/language-modifier-string-format.md
@@ -1,39 +1,43 @@
-string\_format {#language.modifier.string.format}
-==============
+# string_format
This is a way to format strings, such as decimal numbers and such. Use
the syntax for [`sprintf()`](https://www.php.net/sprintf) for the
formatting.
- Parameter Position Type Required Default Description
- -------------------- -------- ---------- --------- ---------------------------------------
- 1 string Yes *n/a* This is what format to use. (sprintf)
+## Basic usage
+```smarty
+{$myVar|string_format:"%d"}
+```
+## Parameters
- <?php
+| Parameter Position | Type | Required | Description |
+|--------------------|--------|----------|---------------------------------------|
+| 1 | string | Yes | This is what format to use. (sprintf) |
- $smarty->assign('number', 23.5787446);
+## Examples
- ?>
+```php
+<?php
-
-
-Where template is:
+$smarty->assign('number', 23.5787446);
+```
- {$number}
- {$number|string_format:"%.2f"}
- {$number|string_format:"%d"}
+Where template is:
-
+```smarty
+{$number}
+{$number|string_format:"%.2f"}
+{$number|string_format:"%d"}
+```
Will output:
+```
+23.5787446
+23.58
+23
+```
- 23.5787446
- 23.58
- 23
-
-
-
-See also [`date_format`](#language.modifier.date.format).
+See also [`date_format`](language-modifier-date-format.md).
diff --git a/docs/designers/language-modifiers/language-modifier-strip-tags.md b/docs/designers/language-modifiers/language-modifier-strip-tags.md
index 4a019767..7d94fdd0 100644
--- a/docs/designers/language-modifiers/language-modifier-strip-tags.md
+++ b/docs/designers/language-modifiers/language-modifier-strip-tags.md
@@ -1,41 +1,46 @@
-strip\_tags {#language.modifier.strip.tags}
-===========
+# strip_tags
-This strips out markup tags, basically anything between `<` and `>`.
+This strips out HTML markup tags, basically anything between `<` and `>`.
- Parameter Position Type Required Default Description
- -------------------- ------ ---------- --------- ----------------------------------------------------------------
- 1 bool No TRUE This determines whether the tags are replaced by \' \' or \'\'
+## Basic usage
+```smarty
+{$myVar|strip_tags}
+```
+## Parameters
- <?php
+| Parameter Position | Type | Required | Default | Description |
+|--------------------|------|----------|---------|------------------------------------------------------------|
+| 1 | bool | No | TRUE | This determines whether the tags are replaced by ' ' or '' |
- $smarty->assign('articleTitle',
- "Blind Woman Gets <font face=\"helvetica\">New
- Kidney</font> from Dad she Hasn't Seen in <b>years</b>."
- );
+## Examples
- ?>
+```php
+<?php
+$smarty->assign('articleTitle',
+ "Blind Woman Gets <font face=\"helvetica\">New
+Kidney</font> from Dad she Hasn't Seen in <b>years</b>."
+ );
+
+```
Where template is:
-
- {$articleTitle}
- {$articleTitle|strip_tags} {* same as {$articleTitle|strip_tags:true} *}
- {$articleTitle|strip_tags:false}
-
-
+```smarty
+{$articleTitle}
+{$articleTitle|strip_tags} {* same as {$articleTitle|strip_tags:true} *}
+{$articleTitle|strip_tags:false}
+```
Will output:
+```html
+Blind Woman Gets <font face="helvetica">New Kidney</font> from Dad she Hasn't Seen in <b>years</b>.
+Blind Woman Gets New Kidney from Dad she Hasn't Seen in years .
+Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.
+```
- Blind Woman Gets <font face="helvetica">New Kidney</font> from Dad she Hasn't Seen in <b>years</b>.
- Blind Woman Gets New Kidney from Dad she Hasn't Seen in years .
- Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.
-
-
-
-See also [`replace`](#language.modifier.replace) and
-[`regex_replace`](#language.modifier.regex.replace).
+See also [`replace`](language-modifier-replace.md) and
+[`regex_replace`](language-modifier-regex-replace.md).
diff --git a/docs/designers/language-modifiers/language-modifier-strip.md b/docs/designers/language-modifiers/language-modifier-strip.md
index 7027e031..b7bdc282 100644
--- a/docs/designers/language-modifiers/language-modifier-strip.md
+++ b/docs/designers/language-modifiers/language-modifier-strip.md
@@ -1,40 +1,42 @@
-strip {#language.modifier.strip}
-=====
+# strip
This replaces all spaces, newlines and tabs with a single space, or with
the supplied string.
+## Basic usage
+```smarty
+{$myVar|strip}
+```
+
> **Note**
>
> If you want to strip blocks of template text, use the built-in
-> [`{strip}`](#language.function.strip) function.
-
+> [`{strip}`](../language-builtin-functions/language-function-strip.md) function.
- <?php
- $smarty->assign('articleTitle', "Grandmother of\neight makes\t hole in one.");
- $smarty->display('index.tpl');
- ?>
+## Examples
-
+```php
+<?php
+$smarty->assign('articleTitle', "Grandmother of\neight makes\t hole in one.");
+$smarty->display('index.tpl');
+```
Where template is:
-
- {$articleTitle}
- {$articleTitle|strip}
- {$articleTitle|strip:'&nbsp;'}
-
-
+```smarty
+{$articleTitle}
+{$articleTitle|strip}
+{$articleTitle|strip:'&nbsp;'}
+```
Will output:
+```html
+Grandmother of
+eight makes hole in one.
+Grandmother of eight makes hole in one.
+Grandmother&nbsp;of&nbsp;eight&nbsp;makes&nbsp;hole&nbsp;in&nbsp;one.
+```
- Grandmother of
- eight makes hole in one.
- Grandmother of eight makes hole in one.
- Grandmother&nbsp;of&nbsp;eight&nbsp;makes&nbsp;hole&nbsp;in&nbsp;one.
-
-
-
-See also [`{strip}`](#language.function.strip) and
-[`truncate`](#language.modifier.truncate).
+See also [`{strip}`](../language-builtin-functions/language-function-strip.md) and
+[`truncate`](language-modifier-truncate.md).
diff --git a/docs/designers/language-modifiers/language-modifier-to-charset.md b/docs/designers/language-modifiers/language-modifier-to-charset.md
index 9389a5ed..c0b00384 100644
--- a/docs/designers/language-modifiers/language-modifier-to-charset.md
+++ b/docs/designers/language-modifiers/language-modifier-to-charset.md
@@ -1,13 +1,14 @@
-to\_charset {#language.modifier.to_charset}
-===========
+# to_charset
`to_charset` is used to transcode a string from the internal charset to
-a given charset. This is the exact opposite of the [from\_charset
+a given charset. This is the exact opposite of the [from_charset
modifier](#language.modifier.from_charset).
- Parameter Position Type Required Possible Values Default Description
- -------------------- -------- ---------- -------------------------------------------------------------------------------------------------------------------------- -------------- -------------------------------------------------------------
- 1 string No `ISO-8859-1`, `UTF-8`, and any character set supported by [`mb_convert_encoding()`](https://www.php.net/mb_convert_encoding) `ISO-8859-1` The charset encoding the value is supposed to be encoded to
+## Parameters
+
+| Parameter Position | Type | Required | Possible Values | Default | Description |
+|--------------------|--------|----------|------------------------------------------------------------------------------------------------------------------------------|--------------|-------------------------------------------------------------|
+| 1 | string | No | `ISO-8859-1`, `UTF-8`, and any character set supported by [`mb_convert_encoding()`](https://www.php.net/mb_convert_encoding) | `ISO-8859-1` | The charset encoding the value is supposed to be encoded to |
> **Note**
>
@@ -15,5 +16,5 @@ modifier](#language.modifier.from_charset).
> modifier should only be used in cases where the application cannot
> anticipate that a certain string is required in another encoding.
-See also [Charset Encoding](#charset), [from\_charset
-modifier](#language.modifier.from_charset).
+See also [Charset Encoding](../../programmers/charset.md), [from_charset
+modifier](language-modifier-from-charset.md).
diff --git a/docs/designers/language-modifiers/language-modifier-truncate.md b/docs/designers/language-modifiers/language-modifier-truncate.md
index 2303a543..1cbb7abc 100644
--- a/docs/designers/language-modifiers/language-modifier-truncate.md
+++ b/docs/designers/language-modifiers/language-modifier-truncate.md
@@ -1,5 +1,4 @@
-truncate {#language.modifier.truncate}
-========
+# truncate
This truncates a variable to a character length, the default is 80. As
an optional second parameter, you can specify a string of text to
@@ -9,44 +8,50 @@ string are included with the original truncation length. By default,
cut off at the exact character length, pass the optional third parameter
of TRUE.
- Parameter Position Type Required Default Description
- -------------------- --------- ---------- --------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- 1 integer No 80 This determines how many characters to truncate to.
- 2 string No \... This is a text string that replaces the truncated text. Its length is included in the truncation length setting.
- 3 boolean No FALSE This determines whether or not to truncate at a word boundary with FALSE, or at the exact character with TRUE.
- 4 boolean No FALSE This determines whether the truncation happens at the end of the string with FALSE, or in the middle of the string with TRUE. Note that if this setting is TRUE, then word boundaries are ignored.
+## Basic usage
+```smarty
+{$myVar|truncate:40:"..."}
+```
+## Parameters
- <?php
- $smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
- ?>
+| Parameter Position | Type | Required | Default | Description |
+|--------------------|---------|----------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| 1 | integer | No | 80 | This determines how many characters to truncate to. |
+| 2 | string | No | \... | This is a text string that replaces the truncated text. Its length is included in the truncation length setting. |
+| 3 | boolean | No | FALSE | This determines whether or not to truncate at a word boundary with FALSE, or at the exact character with TRUE. |
+| 4 | boolean | No | FALSE | This determines whether the truncation happens at the end of the string with FALSE, or in the middle of the string with TRUE. Note that if this setting is TRUE, then word boundaries are ignored. |
-
+## Examples
-where template is:
+```php
+<?php
+$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
+```
+where template is:
- {$articleTitle}
- {$articleTitle|truncate}
- {$articleTitle|truncate:30}
- {$articleTitle|truncate:30:""}
- {$articleTitle|truncate:30:"---"}
- {$articleTitle|truncate:30:"":true}
- {$articleTitle|truncate:30:"...":true}
- {$articleTitle|truncate:30:'..':true:true}
-
-
+```smarty
+{$articleTitle}
+{$articleTitle|truncate}
+{$articleTitle|truncate:30}
+{$articleTitle|truncate:30:""}
+{$articleTitle|truncate:30:"---"}
+{$articleTitle|truncate:30:"":true}
+{$articleTitle|truncate:30:"...":true}
+{$articleTitle|truncate:30:'..':true:true}
+```
This will output:
-
- Two Sisters Reunite after Eighteen Years at Checkout Counter.
- Two Sisters Reunite after Eighteen Years at Checkout Counter.
- Two Sisters Reunite after...
- Two Sisters Reunite after
- Two Sisters Reunite after---
- Two Sisters Reunite after Eigh
- Two Sisters Reunite after E...
- Two Sisters Re..ckout Counter.
-
+```
+Two Sisters Reunite after Eighteen Years at Checkout Counter.
+Two Sisters Reunite after Eighteen Years at Checkout Counter.
+Two Sisters Reunite after...
+Two Sisters Reunite after
+Two Sisters Reunite after---
+Two Sisters Reunite after Eigh
+Two Sisters Reunite after E...
+Two Sisters Re..ckout Counter.
+```
diff --git a/docs/designers/language-modifiers/language-modifier-unescape.md b/docs/designers/language-modifiers/language-modifier-unescape.md
index 1fe9a264..8e860305 100644
--- a/docs/designers/language-modifiers/language-modifier-unescape.md
+++ b/docs/designers/language-modifiers/language-modifier-unescape.md
@@ -1,39 +1,43 @@
-unescape {#language.modifier.unescape}
-========
+# unescape
`unescape` is used to decode `entity`, `html` and `htmlall`. It counters
-the effects of the [escape modifier](#language.modifier.escape) for the
+the effects of the [escape modifier](language-modifier-escape.md) for the
given types.
- Parameter Position Type Required Possible Values Default Description
- -------------------- -------- ---------- ------------------------------------------------------------------------------------------------------------ --------- ------------------------------------------------------------------------------------------------------------------------------
- 1 string No `html`, `htmlall`, `entity`, `html` This is the escape format to use.
- 2 string No `ISO-8859-1`, `UTF-8`, and any character set supported by [`htmlentities()`](https://www.php.net/htmlentities) `UTF-8` The character set encoding passed to html\_entity\_decode() or htmlspecialchars\_decode() or mb\_convert\_encoding() et. al.
+## Basic usage
+```smarty
+{$myVar|unescape}
+```
+## Parameters
- <?php
+| Parameter Position | Type | Required | Possible Values | Default | Description |
+|--------------------|--------|----------|----------------------------------------------------------------------------------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------|
+| 1 | string | No | `html`, `htmlall`, `entity`, | `html` | This is the escape format to use. |
+| 2 | string | No | `ISO-8859-1`, `UTF-8`, and any character set supported by [`htmlentities()`](https://www.php.net/htmlentities) | `UTF-8` | The character set encoding passed to html\_entity\_decode() or htmlspecialchars\_decode() or mb\_convert\_encoding() et. al. |
- $smarty->assign('articleTitle',
- "Germans use &quot;&Uuml;mlauts&quot; and pay in &euro;uro"
- );
+## Examples
- ?>
+```php
+<?php
-
+$smarty->assign('articleTitle',
+ "Germans use &quot;&Uuml;mlauts&quot; and pay in &euro;uro"
+ );
+```
These are example `unescape` template lines followed by the output
+```smarty
+{$articleTitle}
+Germans use &quot;&Uuml;mlauts&quot; and pay in &euro;uro
- {$articleTitle}
- Germans use &quot;&Uuml;mlauts&quot; and pay in &euro;uro
+{$articleTitle|unescape:"html"}
+Germans use "&Uuml;mlauts" and pay in &euro;uro
- {$articleTitle|unescape:"html"}
- Germans use "&Uuml;mlauts" and pay in &euro;uro
+{$articleTitle|unescape:"htmlall"}
+Germans use "Ümlauts" and pay in €uro
+```
- {$articleTitle|unescape:"htmlall"}
- Germans use "Ümlauts" and pay in €uro
-
-
-
-See also [escaping smarty parsing](#language.escaping), [escape
-modifier](#language.modifier.escape).
+See also [escaping smarty parsing](../language-basic-syntax/language-escaping.md), [escape
+modifier](language-modifier-escape.md).
diff --git a/docs/designers/language-modifiers/language-modifier-upper.md b/docs/designers/language-modifiers/language-modifier-upper.md
index adcae0fa..3173059c 100644
--- a/docs/designers/language-modifiers/language-modifier-upper.md
+++ b/docs/designers/language-modifiers/language-modifier-upper.md
@@ -1,31 +1,33 @@
-upper {#language.modifier.upper}
-=====
+# upper
This is used to uppercase a variable. This is equivalent to the PHP
[`strtoupper()`](https://www.php.net/strtoupper) function.
+## Basic usage
+```smarty
+{$myVar|upper}
+```
- <?php
- $smarty->assign('articleTitle', "If Strike isn't Settled Quickly it may Last a While.");
- ?>
+## Examples
-
+```php
+<?php
+$smarty->assign('articleTitle', "If Strike isn't Settled Quickly it may Last a While.");
+```
Where template is:
-
- {$articleTitle}
- {$articleTitle|upper}
-
-
+```smarty
+{$articleTitle}
+{$articleTitle|upper}
+```
Will output:
+```
+If Strike isn't Settled Quickly it may Last a While.
+IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.
+```
- If Strike isn't Settled Quickly it may Last a While.
- IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.
-
-
-
-See also [`lower`](#language.modifier.lower) and
-[`capitalize`](#language.modifier.capitalize).
+See also [`lower`](lower) and
+[`capitalize`](language-modifier-capitalize.md).
diff --git a/docs/designers/language-modifiers/language-modifier-wordwrap.md b/docs/designers/language-modifiers/language-modifier-wordwrap.md
index 49acd696..f3348fd7 100644
--- a/docs/designers/language-modifiers/language-modifier-wordwrap.md
+++ b/docs/designers/language-modifiers/language-modifier-wordwrap.md
@@ -1,5 +1,4 @@
-wordwrap {#language.modifier.wordwrap}
-========
+# wordwrap
Wraps a string to a column width, the default is 80. As an optional
second parameter, you can specify a string of text to wrap the text to
@@ -9,61 +8,66 @@ off at the exact character length, pass the optional third parameter as
TRUE. This is equivalent to the PHP
[`wordwrap()`](https://www.php.net/wordwrap) function.
- Parameter Position Type Required Default Description
- -------------------- --------- ---------- --------- ------------------------------------------------------------------------------------------------------
- 1 integer No 80 This determines how many columns to wrap to.
- 2 string No \\n This is the string used to wrap words with.
- 3 boolean No FALSE This determines whether or not to wrap at a word boundary (FALSE), or at the exact character (TRUE).
+## Basic usage
+```smarty
+{$myVar|wordwrap:30}
+```
+## Parameters
- <?php
+| Parameter Position | Type | Required | Default | Description |
+|--------------------|---------|----------|---------|-----------------------------------------------------------------------------------------------|
+| 1 | integer | No | 80 | This determines how many columns to wrap to. |
+| 2 | string | No | \\n | This is the string used to wrap words with. |
+| 3 | boolean | No | FALSE | This determines whether to wrap at a word boundary (FALSE), or at the exact character (TRUE). |
- $smarty->assign('articleTitle',
- "Blind woman gets new kidney from dad she hasn't seen in years."
- );
+## Examples
- ?>
+```php
+<?php
-
-
-Where template is
+$smarty->assign('articleTitle',
+ "Blind woman gets new kidney from dad she hasn't seen in years."
+ );
+```
- {$articleTitle}
+Where template is
- {$articleTitle|wordwrap:30}
+```smarty
+{$articleTitle}
- {$articleTitle|wordwrap:20}
+{$articleTitle|wordwrap:30}
- {$articleTitle|wordwrap:30:"<br />\n"}
+{$articleTitle|wordwrap:20}
- {$articleTitle|wordwrap:26:"\n":true}
+{$articleTitle|wordwrap:30:"<br />\n"}
-
+{$articleTitle|wordwrap:26:"\n":true}
+```
Will output:
+```html
+Blind woman gets new kidney from dad she hasn't seen in years.
- Blind woman gets new kidney from dad she hasn't seen in years.
-
- Blind woman gets new kidney
- from dad she hasn't seen in
- years.
-
- Blind woman gets new
- kidney from dad she
- hasn't seen in
- years.
+Blind woman gets new kidney
+from dad she hasn't seen in
+years.
- Blind woman gets new kidney<br />
- from dad she hasn't seen in<br />
- years.
+Blind woman gets new
+kidney from dad she
+hasn't seen in
+years.
- Blind woman gets new kidn
- ey from dad she hasn't se
- en in years.
+Blind woman gets new kidney<br />
+from dad she hasn't seen in<br />
+years.
-
+Blind woman gets new kidn
+ey from dad she hasn't se
+en in years.
+```
-See also [`nl2br`](#language.modifier.nl2br) and
-[`{textformat}`](#language.function.textformat).
+See also [`nl2br`](language-modifier-nl2br.md) and
+[`{textformat}`](../language-custom-functions/language-function-textformat.md).