Add mkdocs for docs

This commit is contained in:
Simon Wisselink
2023-02-03 17:54:00 +01:00
parent 6c601e1b6c
commit e6360694bf
42 changed files with 107 additions and 94 deletions

View File

@@ -79,3 +79,17 @@ jobs:
- name: Run tests with phpunit - name: Run tests with phpunit
run: php ./vendor/phpunit/phpunit/phpunit run: php ./vendor/phpunit/phpunit/phpunit
deploy:
runs-on: ubuntu-lastest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: actions/cache@v2
with:
key: ${{ github.ref }}
path: .cache
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force

View File

@@ -14,7 +14,7 @@ shorthand way with Smarty, using the
> **Note** > **Note**
> >
> "Undefined variable" errors will show an E\_NOTICE if not disabled in > "Undefined variable" errors will show an E\_NOTICE if not disabled in
> PHP\'s [`error_reporting()`](&url.php-manual;error_reporting) level or > PHP\'s [`error_reporting()`](https://www.php.net/error_reporting) level or
> Smarty\'s [`$error_reporting`](#variable.error.reporting) property and > Smarty\'s [`$error_reporting`](#variable.error.reporting) property and
> a variable had not been assigned to Smarty. > a variable had not been assigned to Smarty.
@@ -114,7 +114,7 @@ Dates {#tips.dates}
===== =====
As a rule of thumb, always pass dates to Smarty as As a rule of thumb, always pass dates to Smarty as
[timestamps](&url.php-manual;time). This allows template designers to [timestamps](https://www.php.net/time). This allows template designers to
use the [`date_format`](#language.modifier.date.format) modifier for use the [`date_format`](#language.modifier.date.format) modifier for
full control over date formatting, and also makes it easy to compare full control over date formatting, and also makes it easy to compare
dates if necessary. dates if necessary.

View File

@@ -110,7 +110,7 @@ the corresponding error is in the template.
- This means that your application registered a custom error handler - This means that your application registered a custom error handler
(using [set\_error\_handler()](&url.php-manual;set_error_handler)) (using [set\_error\_handler()](https://www.php.net/set_error_handler))
which is not respecting the given `$errno` as it should. If, for which is not respecting the given `$errno` as it should. If, for
whatever reason, this is the desired behaviour of your custom error whatever reason, this is the desired behaviour of your custom error
handler, please call handler, please call

View File

@@ -2,7 +2,8 @@ Basic Syntax
============ ============
A simple Smarty template could look like this: A simple Smarty template could look like this:
```html
```smarty
<h1>{$title|escape}</h1> <h1>{$title|escape}</h1>
<ul> <ul>
{foreach $cities as $city} {foreach $cities as $city}

View File

@@ -4,7 +4,7 @@ Embedding Vars in Double Quotes {#language.syntax.quotes}
- Smarty will recognize [assigned](#api.assign) - Smarty will recognize [assigned](#api.assign)
[variables](#language.syntax.variables) embedded in \"double [variables](#language.syntax.variables) embedded in \"double
quotes\" so long as the variable name contains only numbers, letters quotes\" so long as the variable name contains only numbers, letters
and under\_scores. See [naming](&url.php-manual;language.variables) and under\_scores. See [naming](https://www.php.net/language.variables)
for more detail. for more detail.
- With any other characters, for example a period(.) or - With any other characters, for example a period(.) or

View File

@@ -3,7 +3,7 @@ Variables {#language.syntax.variables}
Template variables start with the \$dollar sign. They can contain Template variables start with the \$dollar sign. They can contain
numbers, letters and underscores, much like a [PHP numbers, letters and underscores, much like a [PHP
variable](&url.php-manual;language.variables). You can reference arrays variable](https://www.php.net/language.variables). You can reference arrays
by index numerically or non-numerically. Also reference object by index numerically or non-numerically. Also reference object
properties and methods. properties and methods.

View File

@@ -8,7 +8,7 @@ Built-in Functions {#language.builtin.functions}
- [{block}](./language-builtin-functions/language-function-block.md) - [{block}](./language-builtin-functions/language-function-block.md)
- [{call}](./language-builtin-functions/language-function-call.md) - [{call}](./language-builtin-functions/language-function-call.md)
- [{capture}](./language-builtin-functions/language-function-capture.md) - [{capture}](./language-builtin-functions/language-function-capture.md)
- [{config_load}](./language-builtin-functions/language-function-config.load) - [{config_load}](./language-builtin-functions/language-function-config-load.md)
- [{debug}](./language-builtin-functions/language-function-debug.md) - [{debug}](./language-builtin-functions/language-function-debug.md)
- [{extends}](./language-builtin-functions/language-function-extends.md) - [{extends}](./language-builtin-functions/language-function-extends.md)
- [{for}](./language-builtin-functions/language-function-for.md) - [{for}](./language-builtin-functions/language-function-for.md)

View File

@@ -2,7 +2,7 @@
==================== ====================
`{if}` statements in Smarty have much the same flexibility as PHP `{if}` statements in Smarty have much the same flexibility as PHP
[if](&url.php-manual;if) statements, with a few added features for the [if](https://www.php.net/if) statements, with a few added features for the
template engine. Every `{if}` must be paired with a matching `{/if}`. template engine. Every `{if}` must be paired with a matching `{/if}`.
`{else}` and `{elseif}` are also permitted. All PHP conditionals and `{else}` and `{elseif}` are also permitted. All PHP conditionals and
functions are recognized, such as *\|\|*, *or*, *&&*, *and*, functions are recognized, such as *\|\|*, *or*, *&&*, *and*,

View File

@@ -37,7 +37,7 @@ be paired with a closing `{/section}` tag.
- The `name` of the `{section}` can be anything you like, made up of - The `name` of the `{section}` can be anything you like, made up of
letters, numbers and underscores, like [PHP letters, numbers and underscores, like [PHP
variables](&url.php-manual;language.variables). variables](https://www.php.net/language.variables).
- {section}\'s can be nested, and the nested `{section}` names must be - {section}\'s can be nested, and the nested `{section}` names must be
unique from each other. unique from each other.
@@ -124,7 +124,7 @@ The above example will output:
The `name` of the `{section}` can be anything you like, see [PHP The `name` of the `{section}` can be anything you like, see [PHP
variables](&url.php-manual;language.variables). It is used to reference variables](https://www.php.net/language.variables). It is used to reference
the data within the `{section}`. the data within the `{section}`.

View File

@@ -2,7 +2,7 @@
======= =======
`{while}` loops in Smarty have much the same flexibility as PHP `{while}` loops in Smarty have much the same flexibility as PHP
[while](&url.php-manual;while) statements, with a few added features for [while](https://www.php.net/while) statements, with a few added features for
the template engine. Every `{while}` must be paired with a matching the template engine. Every `{while}` must be paired with a matching
`{/while}`. All PHP conditionals and functions are recognized, such as `{/while}`. All PHP conditionals and functions are recognized, such as
*\|\|*, *or*, *&&*, *and*, *is\_array()*, etc. *\|\|*, *or*, *&&*, *and*, *is\_array()*, etc.

View File

@@ -74,7 +74,7 @@ Output of the above example would be:
The above arrays would be output with the following template (note the The above arrays would be output with the following template (note the
use of the php [`count()`](&url.php-manual;function.count) function as a use of the php [`count()`](https://www.php.net/function.count) function as a
modifier to set the select size). modifier to set the select size).

View File

@@ -9,7 +9,7 @@ name/value-pairs inside the `<select>` tags of day, month and year.
Attribute Name Type Required Default Description Attribute Name Type Required Default Description
---------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------- ---------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------- ---------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
prefix string No Date\_ What to prefix the var name with prefix string No Date\_ What to prefix the var name with
time [timestamp](&url.php-manual;function.time), [DateTime](&url.php-manual;class.DateTime), mysql timestamp or any string parsable by [`strtotime()`](&url.php-manual;strtotime), arrays as produced by this function if field\_array is set. No current [timestamp](&url.php-manual;function.time) What date/time to pre-select. If an array is given, the attributes field\_array and prefix are used to identify the array elements to extract year, month and day from. Omitting this parameter or supplying a falsy value will select the current date. To prevent date selection, pass in NULL time [timestamp](https://www.php.net/function.time), [DateTime](https://www.php.net/class.DateTime), mysql timestamp or any string parsable by [`strtotime()`](https://www.php.net/strtotime), arrays as produced by this function if field\_array is set. No current [timestamp](https://www.php.net/function.time) What date/time to pre-select. If an array is given, the attributes field\_array and prefix are used to identify the array elements to extract year, month and day from. Omitting this parameter or supplying a falsy value will select the current date. To prevent date selection, pass in NULL
start\_year string No current year The first year in the dropdown, either year number, or relative to current year (+/- N) start\_year string No current year The first year in the dropdown, either year number, or relative to current year (+/- N)
end\_year string No same as start\_year The last year in the dropdown, either year number, or relative to current year (+/- N) end\_year string No same as start\_year The last year in the dropdown, either year number, or relative to current year (+/- N)
display\_days boolean No TRUE Whether to display days or not display\_days boolean No TRUE Whether to display days or not

View File

@@ -7,12 +7,12 @@ minute, second and meridian.
The `time` attribute can have different formats. It can be a unique The `time` attribute can have different formats. It can be a unique
timestamp, a string of the format `YYYYMMDDHHMMSS` or a string that is timestamp, a string of the format `YYYYMMDDHHMMSS` or a string that is
parseable by PHP\'s [`strtotime()`](&url.php-manual;strtotime). parseable by PHP\'s [`strtotime()`](https://www.php.net/strtotime).
Attribute Name Type Required Default Description Attribute Name Type Required Default Description
----------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------- ---------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------- ---------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
prefix string No Time\_ What to prefix the var name with prefix string No Time\_ What to prefix the var name with
time [timestamp](&url.php-manual;function.time), [DateTime](&url.php-manual;class.DateTime), mysql timestamp or any string parsable by [`strtotime()`](&url.php-manual;strtotime), arrays as produced by this function if field\_array is set. No current [timestamp](&url.php-manual;function.time) What date/time to pre-select. If an array is given, the attributes field\_array and prefix are used to identify the array elements to extract hour, minute, second and meridian from. time [timestamp](https://www.php.net/function.time), [DateTime](https://www.php.net/class.DateTime), mysql timestamp or any string parsable by [`strtotime()`](https://www.php.net/strtotime), arrays as produced by this function if field\_array is set. No current [timestamp](https://www.php.net/function.time) What date/time to pre-select. If an array is given, the attributes field\_array and prefix are used to identify the array elements to extract hour, minute, second and meridian from.
display\_hours boolean No TRUE Whether or not to display hours display\_hours boolean No TRUE Whether or not to display hours
display\_minutes boolean No TRUE Whether or not to display minutes display\_minutes boolean No TRUE Whether or not to display minutes
display\_seconds boolean No TRUE Whether or not to display seconds display\_seconds boolean No TRUE Whether or not to display seconds

View File

@@ -13,7 +13,7 @@ template.
- +, -, /, \*, abs, ceil, cos, exp, floor, log, log10, max, min, pi, - +, -, /, \*, abs, ceil, cos, exp, floor, log, log10, max, min, pi,
pow, rand, round, sin, sqrt, srans and tan are all valid operators. pow, rand, round, sin, sqrt, srans and tan are all valid operators.
Check the PHP documentation for further information on these Check the PHP documentation for further information on these
[math](&url.php-manual;eval) functions. [math](https://www.php.net/eval) functions.
- If you supply the `assign` attribute, the output of the `{math}` - If you supply the `assign` attribute, the output of the `{math}`
function will be assigned to this template variable instead of being function will be assigned to this template variable instead of being
@@ -22,7 +22,7 @@ template.
> **Note** > **Note**
> >
> `{math}` is an expensive function in performance due to its use of the > `{math}` is an expensive function in performance due to its use of the
> php [`eval()`](&url.php-manual;eval) function. Doing the math in PHP > php [`eval()`](https://www.php.net/eval) function. Doing the math in PHP
> is much more efficient, so whenever possible do the math calculations > is much more efficient, so whenever possible do the math calculations
> in the script and [`assign()`](#api.assign) the results to the > in the script and [`assign()`](#api.assign) the results to the
> template. Definitely avoid repetitive `{math}` function calls, eg > template. Definitely avoid repetitive `{math}` function calls, eg

View File

@@ -37,7 +37,7 @@ These parameters follow the modifier name and are separated by a `:`
(more below) and modifiers can be (more below) and modifiers can be
[combined](./language-combining-modifiers.md). [combined](./language-combining-modifiers.md).
```smarty
{* apply modifier to a variable *} {* apply modifier to a variable *}
{$title|upper} {$title|upper}
@@ -69,8 +69,7 @@ These parameters follow the modifier name and are separated by a `:`
<select name="name_id"> <select name="name_id">
{html_options output=$my_array|upper|truncate:20} {html_options output=$my_array|upper|truncate:20}
</select> </select>
```
- Modifiers can be applied to any type of variables, including arrays - Modifiers can be applied to any type of variables, including arrays
and objects. and objects.
@@ -97,26 +96,9 @@ These parameters follow the modifier name and are separated by a `:`
> gives 9. To get the old result use parentheses like > gives 9. To get the old result use parentheses like
> `{(8+2)|count_characters}`. > `{(8+2)|count_characters}`.
- Modifiers are autoloaded from the - Custom modifiers can be registered
[`$plugins_dir`](../programmers/api-variables/variable-plugins-dir.md) or can be registered with the [`registerPlugin()`](../programmers/api-functions/api-register-plugin.md)
explicitly with the [`registerPlugin()`](../programmers/api-functions/api-register-plugin.md) function.
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 See also [`registerPlugin()`](../programmers/api-functions/api-register-plugin.md), [combining
modifiers](./language-combining-modifiers.md). and [extending smarty with modifiers](./language-combining-modifiers.md). and [extending smarty with

View File

@@ -2,7 +2,7 @@ capitalize {#language.modifier.capitalize}
========== ==========
This is used to capitalize the first letter of all words in a variable. This is used to capitalize the first letter of all words in a variable.
This is similar to the PHP [`ucwords()`](&url.php-manual;ucwords) This is similar to the PHP [`ucwords()`](https://www.php.net/ucwords)
function. function.
Parameter Position Type Required Default Description Parameter Position Type Required Default Description

View File

@@ -2,11 +2,11 @@ date\_format {#language.modifier.date.format}
============ ============
This formats a date and time into the given This formats a date and time into the given
[`strftime()`](&url.php-manual;strftime) format. Dates can be passed to [`strftime()`](https://www.php.net/strftime) format. Dates can be passed to
Smarty as unix [timestamps](&url.php-manual;function.time), [DateTime Smarty as unix [timestamps](https://www.php.net/function.time), [DateTime
objects](&url.php-manual;class.DateTime), mysql timestamps or any string objects](https://www.php.net/class.DateTime), mysql timestamps or any string
made up of month day year, parsable by php\'s made up of month day year, parsable by php\'s
[`strtotime()`](&url.php-manual;strtotime). Designers can then use [`strtotime()`](https://www.php.net/strtotime). Designers can then use
`date_format` to have complete control of the formatting of the date. If `date_format` to have complete control of the formatting of the date. If
the date passed to `date_format` is empty and a second parameter is the date passed to `date_format` is empty and a second parameter is
passed, that will be used as the date to format. passed, that will be used as the date to format.
@@ -34,9 +34,9 @@ passed, that will be used as the date to format.
> **Note** > **Note**
> >
> `date_format` is essentially a wrapper to PHP\'s > `date_format` is essentially a wrapper to PHP\'s
> [`strftime()`](&url.php-manual;strftime) function. You may have more > [`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()`](&url.php-manual;strftime) function where PHP was > [`strftime()`](https://www.php.net/strftime) function where PHP was
> compiled. Check your system\'s manpage for a full list of valid > compiled. Check your system\'s manpage for a full list of valid
> specifiers. However, a few of the specifiers are emulated on Windows. > specifiers. However, a few of the specifiers are emulated on Windows.
> These are: %D, %e, %h, %l, %n, %r, %R, %t, %T. > These are: %D, %e, %h, %l, %n, %r, %R, %t, %T.
@@ -170,6 +170,6 @@ This above will output:
- \%% - a literal \`%\' character - \%% - a literal \`%\' character
See also [`$smarty.now`](#language.variables.smarty.now), See also [`$smarty.now`](#language.variables.smarty.now),
[`strftime()`](&url.php-manual;strftime), [`strftime()`](https://www.php.net/strftime),
[`{html_select_date}`](#language.function.html.select.date) and the [`{html_select_date}`](#language.function.html.select.date) and the
[date tips](#tips.dates) page. [date tips](#tips.dates) page.

View File

@@ -8,7 +8,7 @@ its `html`.
Parameter Position Type Required Possible Values Default Description 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. 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()`](&url.php-manual;htmlentities) `UTF-8` The character set encoding passed to htmlentities() et. al. 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) 3 boolean No FALSE TRUE Double encode entites from &amp; to &amp;amp; (applys to `html` and `htmlall` only)

View File

@@ -7,7 +7,7 @@ modifier](#language.modifier.to_charset).
Parameter Position Type Required Possible Values Default Description 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()`](&url.php-manual;mb_convert_encoding) `ISO-8859-1` The charset encoding the value is supposed to be decoded from 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** > **Note**
> >

View File

@@ -2,7 +2,7 @@ lower {#language.modifier.lower}
===== =====
This is used to lowercase a variable. This is equivalent to the PHP This is used to lowercase a variable. This is equivalent to the PHP
[`strtolower()`](&url.php-manual;strtolower) function. [`strtolower()`](https://www.php.net/strtolower) function.
<?php <?php

View File

@@ -1,9 +1,9 @@
nl2br {#language.modifier.nl2br} nl2br
===== =====
All `"\n"` line breaks will be converted to html `<br />` tags in the All `"\n"` line breaks will be converted to html `<br />` tags in the
given variable. This is equivalent to the PHP\'s given variable. This is equivalent to the PHP\'s
[`nl2br()`](&url.php-manual;nl2br) function. [`nl2br()`](https://www.php.net/nl2br) function.
<?php <?php

View File

@@ -2,7 +2,7 @@ regex\_replace {#language.modifier.regex.replace}
============== ==============
A regular expression search and replace on a variable. Use the A regular expression search and replace on a variable. Use the
[`preg_replace()`](&url.php-manual;preg_replace) syntax from the PHP [`preg_replace()`](https://www.php.net/preg_replace) syntax from the PHP
manual. manual.
> **Note** > **Note**

View File

@@ -2,7 +2,7 @@ replace {#language.modifier.replace}
======= =======
A simple search and replace on a variable. This is equivalent to the A simple search and replace on a variable. This is equivalent to the
PHP\'s [`str_replace()`](&url.php-manual;str_replace) function. PHP\'s [`str_replace()`](https://www.php.net/str_replace) function.
Parameter Position Type Required Default Description Parameter Position Type Required Default Description
-------------------- -------- ---------- --------- --------------------------------------------- -------------------- -------- ---------- --------- ---------------------------------------------

View File

@@ -2,7 +2,7 @@ string\_format {#language.modifier.string.format}
============== ==============
This is a way to format strings, such as decimal numbers and such. Use This is a way to format strings, such as decimal numbers and such. Use
the syntax for [`sprintf()`](&url.php-manual;sprintf) for the the syntax for [`sprintf()`](https://www.php.net/sprintf) for the
formatting. formatting.
Parameter Position Type Required Default Description Parameter Position Type Required Default Description

View File

@@ -7,7 +7,7 @@ modifier](#language.modifier.from_charset).
Parameter Position Type Required Possible Values Default Description 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()`](&url.php-manual;mb_convert_encoding) `ISO-8859-1` The charset encoding the value is supposed to be encoded to 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** > **Note**
> >

View File

@@ -8,7 +8,7 @@ given types.
Parameter Position Type Required Possible Values Default Description Parameter Position Type Required Possible Values Default Description
-------------------- -------- ---------- ------------------------------------------------------------------------------------------------------------ --------- ------------------------------------------------------------------------------------------------------------------------------ -------------------- -------- ---------- ------------------------------------------------------------------------------------------------------------ --------- ------------------------------------------------------------------------------------------------------------------------------
1 string No `html`, `htmlall`, `entity`, `html` This is the escape format to use. 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()`](&url.php-manual;htmlentities) `UTF-8` The character set encoding passed to html\_entity\_decode() or htmlspecialchars\_decode() or mb\_convert\_encoding() et. al. 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.
<?php <?php

View File

@@ -2,7 +2,7 @@ upper {#language.modifier.upper}
===== =====
This is used to uppercase a variable. This is equivalent to the PHP This is used to uppercase a variable. This is equivalent to the PHP
[`strtoupper()`](&url.php-manual;strtoupper) function. [`strtoupper()`](https://www.php.net/strtoupper) function.
<?php <?php

View File

@@ -7,7 +7,7 @@ the next line, the default is a carriage return `"\n"`. By default,
`wordwrap` will attempt to wrap at a word boundary. If you want to cut `wordwrap` will attempt to wrap at a word boundary. If you want to cut
off at the exact character length, pass the optional third parameter as off at the exact character length, pass the optional third parameter as
TRUE. This is equivalent to the PHP TRUE. This is equivalent to the PHP
[`wordwrap()`](&url.php-manual;wordwrap) function. [`wordwrap()`](https://www.php.net/wordwrap) function.
Parameter Position Type Required Default Description Parameter Position Type Required Default Description
-------------------- --------- ---------- --------- ------------------------------------------------------------------------------------------------------ -------------------- --------- ---------- --------- ------------------------------------------------------------------------------------------------------

View File

@@ -7,7 +7,7 @@ environment and request variables. The full list of them follows.
Request variables {#language.variables.smarty.request} Request variables {#language.variables.smarty.request}
----------------- -----------------
The [request variables](&url.php-manual;reserved.variables) such as The [request variables](https://www.php.net/reserved.variables) such as
`$_GET`, `$_POST`, `$_COOKIE`, `$_SERVER`, `$_ENV` and `$_SESSION` can `$_GET`, `$_POST`, `$_COOKIE`, `$_SERVER`, `$_ENV` and `$_SESSION` can
be accessed as demonstrated in the examples below: be accessed as demonstrated in the examples below:
@@ -54,11 +54,11 @@ be accessed as demonstrated in the examples below:
{\$smarty.now} {#language.variables.smarty.now} {\$smarty.now} {#language.variables.smarty.now}
-------------- --------------
The current [timestamp](&url.php-manual;function.time) can be accessed The current [timestamp](https://www.php.net/function.time) can be accessed
with `{$smarty.now}`. The value reflects the number of seconds passed with `{$smarty.now}`. The value reflects the number of seconds passed
since the so-called Epoch on January 1, 1970, and can be passed directly since the so-called Epoch on January 1, 1970, and can be passed directly
to the [`date_format`](#language.modifier.date.format) modifier for to the [`date_format`](#language.modifier.date.format) modifier for
display. Note that [`time()`](&url.php-manual;function.time) is called display. Note that [`time()`](https://www.php.net/function.time) is called
on each invocation; eg a script that takes three seconds to execute with on each invocation; eg a script that takes three seconds to execute with
a call to `$smarty.now` at start and end will show the three second a call to `$smarty.now` at start and end will show the three second
difference. difference.

View File

@@ -2,25 +2,25 @@ What is Smarty?
============== ==============
## Requirements ## Requirements
Smarty can be run with PHP 7.1 to PHP 8.2. Smarty can be run with PHP 7.2 to PHP 8.2.
## Installation ## Installation
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/). Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).
To get the latest stable version of Smarty use: To get the latest stable version of Smarty use:
```bash ```sh
composer require smarty/smarty composer require smarty/smarty
```` ```
To get the latest, unreleased version, use: To get the latest, unreleased version, use:
```bash ```sh
composer require smarty/smarty:dev-master composer require smarty/smarty:dev-master
```` ```
To get the previous stable version of Smarty, Smarty 3, use: To get the previous stable version of Smarty, Smarty 3, use:
```bash ```sh
composer require smarty/smarty:^3 composer require smarty/smarty:^3
```` ```
Here's how you create an instance of Smarty in your PHP scripts: Here's how you create an instance of Smarty in your PHP scripts:
```php ```php
@@ -42,7 +42,10 @@ Smarty requires four directories which are by default named
relative to the current working directory. relative to the current working directory.
The defaults can be changed as follows: The defaults can be changed as follows:
```php ```php
<?php
$smarty = new Smarty(); $smarty = new Smarty();
$smarty->setTemplateDir('/some/template/dir'); $smarty->setTemplateDir('/some/template/dir');
$smarty->setConfigDir('/some/config/dir'); $smarty->setConfigDir('/some/config/dir');
@@ -82,7 +85,7 @@ $smarty->testInstall();
Now, let's create the `index.tpl` file that Smarty will display. This Now, let's create the `index.tpl` file that Smarty will display. This
needs to be located in the [`$template_dir`](./programmers/api-variables/variable-template-dir.md). needs to be located in the [`$template_dir`](./programmers/api-variables/variable-template-dir.md).
```html ```smarty
{* Smarty *} {* Smarty *}
Hello {$name}, welcome to Smarty! Hello {$name}, welcome to Smarty!
``` ```

BIN
docs/images/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@@ -2,7 +2,7 @@
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
It allows you to write **templates**, using **variables**, **modifiers**, **functions** and **comments**, like this: It allows you to write **templates**, using **variables**, **modifiers**, **functions** and **comments**, like this:
```html ```smarty
<h1>{$title|escape}</h1> <h1>{$title|escape}</h1>
<p> <p>

View File

@@ -1,7 +1,7 @@
Objects {#advanced.features.objects} Objects {#advanced.features.objects}
======= =======
Smarty allows access to PHP [objects](&url.php-manual;object) through Smarty allows access to PHP [objects](https://www.php.net/object) through
the templates. the templates.
> **Note** > **Note**

View File

@@ -69,7 +69,7 @@ The `email_body.tpl` template
The php script using the PHP [`mail()`](&url.php-manual;function.mail) The php script using the PHP [`mail()`](https://www.php.net/function.mail)
function function

View File

@@ -10,7 +10,7 @@ string
muteExpectedErrors muteExpectedErrors
muteExpectedErrors() registers a custom error handler using muteExpectedErrors() registers a custom error handler using
[set\_error\_handler()](&url.php-manual;set_error_handler). The error [set\_error\_handler()](https://www.php.net/set_error_handler). The error
handler merely inspects `$errno` and `$errfile` to determine if the handler merely inspects `$errno` and `$errfile` to determine if the
given error was produced deliberately and must be ignored, or should be given error was produced deliberately and must be ignored, or should be
passed on to the next error handler. passed on to the next error handler.

View File

@@ -2,7 +2,7 @@
================== ==================
When this value is set to a non-null-value it\'s value is used as php\'s When this value is set to a non-null-value it\'s value is used as php\'s
[`error_reporting`](&url.php-manual;error_reporting) level inside of [`error_reporting`](https://www.php.net/error_reporting) level inside of
[`display()`](#api.display) and [`fetch()`](#api.fetch). [`display()`](#api.display) and [`fetch()`](#api.fetch).
Smarty 3.1.2 introduced the Smarty 3.1.2 introduced the

View File

@@ -19,7 +19,7 @@ almost nothing.
> **Note** > **Note**
> >
> - `$use_sub_dirs=true` doesn\'t work with > - `$use_sub_dirs=true` doesn\'t work with
> [safe\_mode=On](&url.php-manual;features.safe-mode), that\'s why > [safe\_mode=On](https://www.php.net/features.safe-mode), that\'s why
> it\'s switchable and why it\'s off by default. > it\'s switchable and why it\'s off by default.
> >
> - `$use_sub_dirs=true` on Windows can cause problems. > - `$use_sub_dirs=true` on Windows can cause problems.

View File

@@ -1,8 +1,4 @@
Charset Encoding {#charset} # Charset Encoding
================
Charset Encoding {#charset.encoding}
================
There are a variety of encodings for textual data, ISO-8859-1 (Latin1) There are a variety of encodings for textual data, ISO-8859-1 (Latin1)
and UTF-8 being the most popular. Unless you change `\Smarty\Smarty::$_CHARSET`, and UTF-8 being the most popular. Unless you change `\Smarty\Smarty::$_CHARSET`,
@@ -26,14 +22,14 @@ Smarty recognizes `UTF-8` as the internal charset.
> Smarty\'s internals and core plugins are truly UTF-8 compatible since > Smarty\'s internals and core plugins are truly UTF-8 compatible since
> Smarty 3.1. > Smarty 3.1.
```php
<?php
// use japanese character encoding
mb_internal_charset('EUC-JP');
// use japanese character encoding \Smarty\Smarty::$_CHARSET = 'EUC-JP';
if (function_exists('mb_internal_charset')) { $smarty = new \Smarty\Smarty();
mb_internal_charset('EUC-JP');
}
require_once 'libs/Smarty.class.php'; ```
Smarty::$_CHARSET = 'EUC-JP';
$smarty = new Smarty();

View File

@@ -25,7 +25,7 @@ The first parameter to the modifier plugin is the value on which the
modifier is to operate. The rest of the parameters are optional, modifier is to operate. The rest of the parameters are optional,
depending on what kind of operation is to be performed. depending on what kind of operation is to be performed.
The modifier has to [return](&url.php-manual;return) the result of its The modifier has to [return](https://www.php.net/return) the result of its
processing. processing.
This plugin basically aliases one of the built-in PHP functions. It does This plugin basically aliases one of the built-in PHP functions. It does

View File

@@ -30,7 +30,7 @@ in order to be located by Smarty.
- And `name` should be a valid identifier; letters, numbers, and - And `name` should be a valid identifier; letters, numbers, and
underscores only, see [php underscores only, see [php
variables](&url.php-manual;language.variables). variables](https://www.php.net/language.variables).
- Some examples: `function.html_select_date.php`, `resource.db.php`, - Some examples: `function.html_select_date.php`, `resource.db.php`,
`modifier.spacify.php`. `modifier.spacify.php`.

View File

@@ -46,8 +46,8 @@ From within a Smarty template
Both `string:` and `eval:` resources may be encoded with Both `string:` and `eval:` resources may be encoded with
[`urlencode()`](&url.php-manual;urlencode) or [`urlencode()`](https://www.php.net/urlencode) or
[`base64_encode()`](&url.php-manual;urlencode). This is not necessary [`base64_encode()`](https://www.php.net/urlencode). This is not necessary
for the usual use of `string:` and `eval:`, but is required when using for the usual use of `string:` and `eval:`, but is required when using
either of them in conjunction with either of them in conjunction with
[`Extends Template Resource`](#resources.extends) [`Extends Template Resource`](#resources.extends)

17
mkdocs.yml Normal file
View File

@@ -0,0 +1,17 @@
site_name: Smarty Documentation
theme:
name: material
palette:
primary: amber
features:
- content.code.copy
icon:
logo: material/lightbulb-on
favicon: images/favicon.ico
markdown_extensions:
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences