summaryrefslogtreecommitdiff
path: root/docs/designers
diff options
context:
space:
mode:
Diffstat (limited to 'docs/designers')
-rw-r--r--docs/designers/chapter-debugging-console.md3
-rw-r--r--docs/designers/language-basic-syntax/index.md2
-rw-r--r--docs/designers/language-basic-syntax/language-escaping.md2
-rw-r--r--docs/designers/language-basic-syntax/language-math.md28
-rw-r--r--docs/designers/language-basic-syntax/language-syntax-functions.md1
-rw-r--r--docs/designers/language-basic-syntax/language-syntax-operators.md64
-rw-r--r--docs/designers/language-builtin-functions.md0
-rw-r--r--docs/designers/language-builtin-functions/language-function-assign.md1
-rw-r--r--docs/designers/language-builtin-functions/language-function-capture.md6
-rw-r--r--docs/designers/language-builtin-functions/language-function-foreach.md2
-rw-r--r--docs/designers/language-builtin-functions/language-function-if.md4
-rw-r--r--docs/designers/language-builtin-functions/language-function-include.md2
-rw-r--r--docs/designers/language-builtin-functions/language-function-insert.md86
-rw-r--r--docs/designers/language-builtin-functions/language-function-nocache.md2
-rw-r--r--docs/designers/language-custom-functions/language-function-mailto.md4
-rw-r--r--docs/designers/language-modifiers/index.md25
-rw-r--r--docs/designers/language-modifiers/language-modifier-from-charset.md2
-rw-r--r--docs/designers/language-modifiers/language-modifier-to-charset.md2
-rw-r--r--docs/designers/language-variables/language-assigned-variables.md2
-rw-r--r--docs/designers/language-variables/language-variables-smarty.md3
20 files changed, 80 insertions, 161 deletions
diff --git a/docs/designers/chapter-debugging-console.md b/docs/designers/chapter-debugging-console.md
index 6704fce2..50acd195 100644
--- a/docs/designers/chapter-debugging-console.md
+++ b/docs/designers/chapter-debugging-console.md
@@ -10,8 +10,7 @@ of the console.
Set [`$debugging`](../programmers/api-variables/variable-debugging.md) to TRUE in Smarty, and if needed
set [`$debug_tpl`](../programmers/api-variables/variable-debug-template.md) to the template resource
-path to `debug.tpl` (this is in [`SMARTY_DIR`](../programmers/smarty-constants.md) by
-default). When you load the page, a Javascript console window will pop
+path to `debug.tpl`. When you load the page, a Javascript console window will pop
up and give you the names of all the included templates and assigned
variables for the current page.
diff --git a/docs/designers/language-basic-syntax/index.md b/docs/designers/language-basic-syntax/index.md
index c0a12a9b..05c0ba69 100644
--- a/docs/designers/language-basic-syntax/index.md
+++ b/docs/designers/language-basic-syntax/index.md
@@ -26,8 +26,8 @@ The basis components of the Smarty syntax are:
- [Comments](language-syntax-comments.md)
- [Variables](language-syntax-variables.md)
+- [Operators](language-syntax-operators.md)
- [Functions](language-syntax-functions.md)
- [Attributes](language-syntax-attributes.md)
- [Quotes](language-syntax-quotes.md)
-- [Math](language-math.md)
- [Escaping](language-escaping.md)
diff --git a/docs/designers/language-basic-syntax/language-escaping.md b/docs/designers/language-basic-syntax/language-escaping.md
index 4c75e09e..58e75d58 100644
--- a/docs/designers/language-basic-syntax/language-escaping.md
+++ b/docs/designers/language-basic-syntax/language-escaping.md
@@ -69,7 +69,7 @@ Where the template is:
```smarty
Welcome <!--{$name}--> to Smarty
-<script language="javascript">
+ <script>
var foo = <!--{$foo}-->;
function dosomething() {
alert("foo is " + foo);
diff --git a/docs/designers/language-basic-syntax/language-math.md b/docs/designers/language-basic-syntax/language-math.md
deleted file mode 100644
index a9a43efd..00000000
--- a/docs/designers/language-basic-syntax/language-math.md
+++ /dev/null
@@ -1,28 +0,0 @@
-# Math
-
-Math can be applied directly to variable values.
-
-## Examples
-```smarty
-{$foo+1}
-
-{$foo*$bar}
-
-{* some more complicated examples *}
-
-{$foo->bar-$bar[1]*$baz->foo->bar()-3*7}
-
-{if ($foo+$bar.test%$baz*134232+10+$b+10)}
-
-{$foo|truncate:"`$fooTruncCount/$barTruncFactor-1`"}
-
-{assign var="foo" value="`$foo+$bar`"}
-```
-
-> **Note**
->
-> Although Smarty can handle some very complex expressions and syntax,
-> it is a good rule of thumb to keep the template syntax minimal and
-> focused on presentation. If you find your template syntax getting too
-> complex, it may be a good idea to move the bits that do not deal
-> explicitly with presentation to PHP by way of plugins or modifiers.
diff --git a/docs/designers/language-basic-syntax/language-syntax-functions.md b/docs/designers/language-basic-syntax/language-syntax-functions.md
index c3c8c21c..93d94f6b 100644
--- a/docs/designers/language-basic-syntax/language-syntax-functions.md
+++ b/docs/designers/language-basic-syntax/language-syntax-functions.md
@@ -11,7 +11,6 @@ within delimiters like so: `{funcname attr1="val1" attr2="val2"}`.
{config_load file="colors.conf"}
{include file="header.tpl"}
-{insert file="banner_ads.tpl" title="My Site"}
{if $logged_in}
Welcome, <span style="color:{#fontColor#}">{$name}!</span>
diff --git a/docs/designers/language-basic-syntax/language-syntax-operators.md b/docs/designers/language-basic-syntax/language-syntax-operators.md
new file mode 100644
index 00000000..98eff076
--- /dev/null
+++ b/docs/designers/language-basic-syntax/language-syntax-operators.md
@@ -0,0 +1,64 @@
+# Operators
+
+## Basic
+
+Various basic operators can be applied directly to variable values.
+
+## Examples
+```smarty
+{$foo + 1}
+
+{$foo * $bar}
+
+{$foo->bar - $bar[1] * $baz->foo->bar() -3 * 7}
+
+{if ($foo + $bar.test % $baz * 134232 + 10 + $b + 10)}
+ ...
+{/if}
+
+{$foo = $foo + $bar}
+```
+
+> **Note**
+>
+> Although Smarty can handle some very complex expressions and syntax,
+> it is a good rule of thumb to keep the template syntax minimal and
+> focused on presentation. If you find your template syntax getting too
+> complex, it may be a good idea to move the bits that do not deal
+> explicitly with presentation to PHP by way of plugins or modifiers.
+
+## Ternary
+You can use the `?:` (or ternary) operator to test one expression and present the value
+of the second or third expression, based on the result of the test.
+
+In other words:
+```smarty
+{$test ? "OK" : "FAIL"}
+```
+will result in OK if `$test` is set to true, and in FAIL otherwise.
+
+There is also a shorthand `?:` operator:
+```smarty
+{$myVar ?: "empty"}
+```
+will result in 'empty' if `$myVar` is not set or set to something that evaluates to false, such as an empty string.
+If `$myVar` is set to something that evaluates to true, the value of `$myVar` is returned. So, the following will
+return 'hello':
+```smarty
+{$myVar="hello"}
+{$myVar ?: "empty"}
+```
+
+## Testing for null
+If "something that evaluates to false" is to broad a test for you, you can use the `??` (or null coalescing) operator
+to trigger only if the tested value is undefined or set to null.
+```smarty
+{$myVar ?? "empty"}
+```
+will result in 'empty' if `$myVar` is not set or set to null.
+If `$myVar` is set to something that evaluates to anything else, the value of `$myVar` is returned. So, the following will
+return an empty string (''):
+```smarty
+{$myVar=""}
+{$myVar ?: "this is not shown"}
+``` \ No newline at end of file
diff --git a/docs/designers/language-builtin-functions.md b/docs/designers/language-builtin-functions.md
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/docs/designers/language-builtin-functions.md
diff --git a/docs/designers/language-builtin-functions/language-function-assign.md b/docs/designers/language-builtin-functions/language-function-assign.md
index f5faa46d..518e3f7d 100644
--- a/docs/designers/language-builtin-functions/language-function-assign.md
+++ b/docs/designers/language-builtin-functions/language-function-assign.md
@@ -134,7 +134,6 @@ echo $smarty->getTemplateVars('foo');
The following functions can also *optionally* assign template variables: [`{capture}`](#language.function.capture),
[`{include}`](#language.function.include),
-[`{insert}`](#language.function.insert),
[`{counter}`](#language.function.counter),
[`{cycle}`](#language.function.cycle),
[`{eval}`](#language.function.eval),
diff --git a/docs/designers/language-builtin-functions/language-function-capture.md b/docs/designers/language-builtin-functions/language-function-capture.md
index 657f077c..83f4d02d 100644
--- a/docs/designers/language-builtin-functions/language-function-capture.md
+++ b/docs/designers/language-builtin-functions/language-function-capture.md
@@ -27,12 +27,6 @@ is the value passed in the `name` attribute. If you do not supply the
|---------|-----------------------------------------|
| nocache | Disables caching of this captured block |
-> **Note**
->
-> Be careful when capturing [`{insert}`](#language.function.insert)
-> output. If you have [`$caching`](#caching) enabled and you have
-> [`{insert}`](#language.function.insert) commands that you expect to
-> run within cached content, do not capture this content.
## Examples
diff --git a/docs/designers/language-builtin-functions/language-function-foreach.md b/docs/designers/language-builtin-functions/language-function-foreach.md
index 645d6c52..a0b7b588 100644
--- a/docs/designers/language-builtin-functions/language-function-foreach.md
+++ b/docs/designers/language-builtin-functions/language-function-foreach.md
@@ -166,7 +166,7 @@ looping over a PHP iterator instead of an array().
```php
<?php
- include('Smarty.class.php');
+ use Smarty\Smarty;
$smarty = new Smarty;
diff --git a/docs/designers/language-builtin-functions/language-function-if.md b/docs/designers/language-builtin-functions/language-function-if.md
index c7be37a2..1372ea58 100644
--- a/docs/designers/language-builtin-functions/language-function-if.md
+++ b/docs/designers/language-builtin-functions/language-function-if.md
@@ -7,10 +7,6 @@ template engine. Every `{if}` must be paired with a matching `{/if}`.
functions are recognized, such as *\|\|*, *or*, *&&*, *and*,
*is_array()*, etc.
-If security is enabled, only PHP functions from `$php_functions` property
-of the security policy are allowed. See the
-[Security](../../programmers/advanced-features/advanced-features-security.md) section for details.
-
The following is a list of recognized qualifiers, which must be
separated from surrounding elements by spaces. Note that items listed in
\[brackets\] are optional. PHP equivalents are shown where applicable.
diff --git a/docs/designers/language-builtin-functions/language-function-include.md b/docs/designers/language-builtin-functions/language-function-include.md
index d12a817e..54660cd5 100644
--- a/docs/designers/language-builtin-functions/language-function-include.md
+++ b/docs/designers/language-builtin-functions/language-function-include.md
@@ -183,5 +183,5 @@ current template.
{include file="$style_dir/$module.$view.tpl"}
```
-See also [`{insert}`](./language-function-insert.md), [template resources](../../programmers/resources.md) and
+See also [template resources](../../programmers/resources.md) and
[componentized templates](../../appendixes/tips.md#componentized-templates).
diff --git a/docs/designers/language-builtin-functions/language-function-insert.md b/docs/designers/language-builtin-functions/language-function-insert.md
index 54f0729d..e69de29b 100644
--- a/docs/designers/language-builtin-functions/language-function-insert.md
+++ b/docs/designers/language-builtin-functions/language-function-insert.md
@@ -1,86 +0,0 @@
-# {insert}
-
-> **Note**
->
-> `{insert}` tags are deprecated from Smarty, and should not be used.
-> Put your PHP logic in PHP scripts or plugin functions instead.
-> As of Smarty 3.1 the `{insert}` tags are only available from
-> [SmartyBC](#bc).
-
-`{insert}` tags work much like [`{include}`](./language-function-include.md)
-tags, except that `{insert}` tags are NOT cached when template
-[caching](../../programmers/caching.md) is enabled. They will be executed on every
-invocation of the template.
-
-| Attribute Name | Required | Description |
-|----------------|----------|----------------------------------------------------------------------------------|
-| name | Yes | The name of the insert function (insert_`name`) or insert plugin |
-| assign | No | The name of the template variable the output will be assigned to |
-| script | No | The name of the php script that is included before the insert function is called |
-| \[var \...\] | No | variable to pass to insert function |
-
-## Examples
-
-Let's say you have a template with a banner slot at the top of the
-page. The banner can contain any mixture of HTML, images, flash, etc. so
-we can't just use a static link here, and we don't want this contents
-cached with the page. In comes the {insert} tag: the template knows
-\#banner\_location\_id\# and \#site\_id\# values (gathered from a
-[config file](../config-files.md)), and needs to call a function to get the
-banner contents.
-
-```smarty
- {* example of fetching a banner *}
- {insert name="getBanner" lid=#banner_location_id# sid=#site_id#}
- {insert "getBanner" lid=#banner_location_id# sid=#site_id#} {* short-hand *}
-```
-
-In this example, we are using the name "getBanner" and passing the
-parameters \#banner\_location\_id\# and \#site\_id\#. Smarty will look
-for a function named insert\_getBanner() in your PHP application,
-passing the values of \#banner\_location\_id\# and \#site\_id\# as the
-first argument in an associative array. All {insert} function names in
-your application must be prepended with "insert_" to remedy possible
-function name-space conflicts. Your insert\_getBanner() function should
-do something with the passed values and return the results. These
-results are then displayed in the template in place of the {insert} tag.
-In this example, Smarty would call this function:
-insert_getBanner(array("lid" => "12345","sid" => "67890"));
-and display the returned results in place of the {insert} tag.
-
-- If you supply the `assign` attribute, the output of the `{insert}`
- tag will be assigned to this template variable instead of being
- output to the template.
-
- > **Note**
- >
- > Assigning the output to a template variable isn't too useful with
- > [caching](../../programmers/api-variables/variable-caching.md) enabled.
-
-- If you supply the `script` attribute, this php script will be
- included (only once) before the `{insert}` function is executed.
- This is the case where the insert function may not exist yet, and a
- php script must be included first to make it work.
-
- The path can be either absolute, or relative to
- [`$trusted_dir`](../../programmers/api-variables/variable-trusted-dir.md). If security is enabled,
- then the script must be located in the `$trusted_dir` path of the
- security policy. See the [Security](../../programmers/advanced-features/advanced-features-security.md)
- section for details.
-
-The Smarty object is passed as the second argument. This way you can
-reference and modify information in the Smarty object from within the
-`{insert}` function.
-
-If no PHP script can be found Smarty is looking for a corresponding
-insert plugin.
-
-> **Note**
->
-> It is possible to have portions of the template not cached. If you
-> have [caching](../../programmers/api-variables/variable-caching.md) turned on, `{insert}` tags will not be
-> cached. They will run dynamically every time the page is created, even
-> within cached pages. This works good for things like banners, polls,
-> live weather, search results, user feedback areas, etc.
-
-See also [`{include}`](./language-function-include.md)
diff --git a/docs/designers/language-builtin-functions/language-function-nocache.md b/docs/designers/language-builtin-functions/language-function-nocache.md
index e6d8453f..7997ecfb 100644
--- a/docs/designers/language-builtin-functions/language-function-nocache.md
+++ b/docs/designers/language-builtin-functions/language-function-nocache.md
@@ -17,4 +17,4 @@ Today's date is
The above code will output the current date on a cached page.
-See also the [caching section](../../programmers/caching.md).
+See also the [caching section](../../api/caching/basics.md).
diff --git a/docs/designers/language-custom-functions/language-function-mailto.md b/docs/designers/language-custom-functions/language-function-mailto.md
index bcb8b7d4..c32c2387 100644
--- a/docs/designers/language-custom-functions/language-function-mailto.md
+++ b/docs/designers/language-custom-functions/language-function-mailto.md
@@ -34,7 +34,7 @@ spiders to lift email addresses off of a site.
<a href="mailto:me@example.com" >send me some mail</a>
{mailto address="me@example.com" encode="javascript"}
-<script type="text/javascript" language="javascript">
+ <script>
eval(unescape('%64%6f% ... snipped ...%61%3e%27%29%3b'))
</script>
@@ -51,7 +51,7 @@ spiders to lift email addresses off of a site.
<a href="mailto:me@example.com" class="email">me@example.com</a>
{mailto address="me@example.com" encode="javascript_charcode"}
-<script type="text/javascript" language="javascript">
+ <script>
{document.write(String.fromCharCode(60,97, ... snipped ....60,47,97,62))}
</script>
```
diff --git a/docs/designers/language-modifiers/index.md b/docs/designers/language-modifiers/index.md
index c9aeef88..a384c95c 100644
--- a/docs/designers/language-modifiers/index.md
+++ b/docs/designers/language-modifiers/index.md
@@ -69,7 +69,7 @@ These parameters follow the modifier name and are separated by a `:`
<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.
@@ -96,26 +96,9 @@ These parameters follow the modifier name and are separated by a `:`
> 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.
+- Custom modifiers can be registered
+ with the [`registerPlugin()`](../../programmers/api-functions/api-register-plugin.md)
+ function.
See also [`registerPlugin()`](../../programmers/api-functions/api-register-plugin.md), [combining
modifiers](../language-combining-modifiers.md). and [extending smarty with
diff --git a/docs/designers/language-modifiers/language-modifier-from-charset.md b/docs/designers/language-modifiers/language-modifier-from-charset.md
index bf4b4769..25c4d2d9 100644
--- a/docs/designers/language-modifiers/language-modifier-from-charset.md
+++ b/docs/designers/language-modifiers/language-modifier-from-charset.md
@@ -16,5 +16,5 @@ modifier](language-modifier-to-charset.md).
> 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](../../programmers/charset.md), [to_charset
+See also [Configuring Smarty](../../api/configuring.md), [to_charset
modifier](language-modifier-to-charset.md).
diff --git a/docs/designers/language-modifiers/language-modifier-to-charset.md b/docs/designers/language-modifiers/language-modifier-to-charset.md
index c0b00384..aa8cfd53 100644
--- a/docs/designers/language-modifiers/language-modifier-to-charset.md
+++ b/docs/designers/language-modifiers/language-modifier-to-charset.md
@@ -16,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](../../programmers/charset.md), [from_charset
+See also [Configuring Smarty](../../api/configuring.md), [from_charset
modifier](language-modifier-from-charset.md).
diff --git a/docs/designers/language-variables/language-assigned-variables.md b/docs/designers/language-variables/language-assigned-variables.md
index bd356a2b..a358008f 100644
--- a/docs/designers/language-variables/language-assigned-variables.md
+++ b/docs/designers/language-variables/language-assigned-variables.md
@@ -7,7 +7,7 @@ Variables assigned from PHP are referenced by preceding them with a dollar
```php
<?php
-
+use Smarty\Smarty;
$smarty = new Smarty();
$smarty->assign('firstname', 'Doug');
diff --git a/docs/designers/language-variables/language-variables-smarty.md b/docs/designers/language-variables/language-variables-smarty.md
index da543fb6..b6dff73a 100644
--- a/docs/designers/language-variables/language-variables-smarty.md
+++ b/docs/designers/language-variables/language-variables-smarty.md
@@ -66,8 +66,7 @@ difference.
## {$smarty.const}
-You can access PHP constant values directly. See also [smarty
-constants](../../programmers/smarty-constants.md).
+You can access PHP constant values directly.
```php
<?php