aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/smarty/smarty/docs/designers/language-basic-syntax
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/smarty/smarty/docs/designers/language-basic-syntax')
-rw-r--r--vendor/smarty/smarty/docs/designers/language-basic-syntax/language-escaping.md84
-rw-r--r--vendor/smarty/smarty/docs/designers/language-basic-syntax/language-math.md29
-rw-r--r--vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-attributes.md50
-rw-r--r--vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-comments.md71
-rw-r--r--vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-functions.md40
-rw-r--r--vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-quotes.md61
-rw-r--r--vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-variables.md111
7 files changed, 446 insertions, 0 deletions
diff --git a/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-escaping.md b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-escaping.md
new file mode 100644
index 000000000..a62e7de89
--- /dev/null
+++ b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-escaping.md
@@ -0,0 +1,84 @@
+Escaping Smarty Parsing {#language.escaping}
+=======================
+
+It is sometimes desirable or even necessary to have Smarty ignore
+sections it would otherwise parse. A classic example is embedding
+Javascript or CSS code in a template. The problem arises as those
+languages use the { and } characters which are also the default
+[delimiters](#language.function.ldelim) for Smarty.
+
+> **Note**
+>
+> A good practice for avoiding escapement altogether is by separating
+> your Javascript/CSS into their own files and use standard HTML methods
+> to access them. This will also take advantage of browser script
+> caching. When you need to embed Smarty variables/functions into your
+> Javascript/CSS, then the following applies.
+
+In Smarty templates, the { and } braces will be ignored so long as they
+are surrounded by white space. This behavior can be disabled by setting
+the Smarty class variable [`$auto_literal`](#variable.auto.literal) to
+false.
+
+
+ <script>
+ // the following braces are ignored by Smarty
+ // since they are surrounded by whitespace
+ function foobar {
+ alert('foobar!');
+ }
+ // this one will need literal escapement
+ {literal}
+ function bazzy {alert('foobar!');}
+ {/literal}
+ </script>
+
+
+
+[`{literal}..{/literal}`](#language.function.literal) blocks are used
+for escaping blocks of template logic. You can also escape the braces
+individually with
+[`{ldelim}`](#language.function.ldelim),[`{rdelim}`](#language.function.ldelim)
+tags or
+[`{$smarty.ldelim}`,`{$smarty.rdelim}`](#language.variables.smarty.ldelim)
+variables.
+
+Smarty\'s default delimiters { and } cleanly represent presentational
+content. However if another set of delimiters suit your needs better,
+you can change them with Smarty\'s
+[`$left_delimiter`](#variable.left.delimiter) and
+[`$right_delimiter`](#variable.right.delimiter) values.
+
+> **Note**
+>
+> Changing delimiters affects ALL template syntax and escapement. Be
+> sure to clear out cache and compiled files if you decide to change
+> them.
+
+
+ <?php
+
+ $smarty->left_delimiter = '<!--{';
+ $smarty->right_delimiter = '}-->';
+
+ $smarty->assign('foo', 'bar');
+ $smarty->assign('name', 'Albert');
+ $smarty->display('example.tpl');
+
+ ?>
+
+
+
+Where the template is:
+
+
+ Welcome <!--{$name}--> to Smarty
+ <script language="javascript">
+ var foo = <!--{$foo}-->;
+ function dosomething() {
+ alert("foo is " + foo);
+ }
+ dosomething();
+ </script>
+
+
diff --git a/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-math.md b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-math.md
new file mode 100644
index 000000000..dc78a3512
--- /dev/null
+++ b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-math.md
@@ -0,0 +1,29 @@
+Math {#language.math}
+====
+
+Math can be applied directly to variable values.
+
+
+ {$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/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-attributes.md b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-attributes.md
new file mode 100644
index 000000000..0fa7c7734
--- /dev/null
+++ b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-attributes.md
@@ -0,0 +1,50 @@
+Attributes {#language.syntax.attributes}
+==========
+
+Most of the [functions](#language.syntax.functions) take attributes that
+specify or modify their behavior. Attributes to Smarty functions are
+much like HTML attributes. Static values don\'t have to be enclosed in
+quotes, but it is required for literal strings. Variables with or
+without modifiers may also be used, and should not be in quotes. You can
+even use PHP function results, plugin results and complex expressions.
+
+Some attributes require boolean values (TRUE or FALSE). These can be
+specified as `true` and `false`. If an attribute has no value assigned
+it gets the default boolean value of true.
+
+
+ {include file="header.tpl"}
+
+ {include file="header.tpl" nocache} // is equivalent to nocache=true
+
+ {include file="header.tpl" attrib_name="attrib value"}
+
+ {include file=$includeFile}
+
+ {include file=#includeFile# title="My Title"}
+
+ {assign var=foo value={counter}} // plugin result
+
+ {assign var=foo value=substr($bar,2,5)} // PHP function result
+
+ {assign var=foo value=$bar|strlen} // using modifier
+
+ {assign var=foo value=$buh+$bar|strlen} // more complex expression
+
+ {html_select_date display_days=true}
+
+ {mailto address="smarty@example.com"}
+
+ <select name="company_id">
+ {html_options options=$companies selected=$company_id}
+ </select>
+
+
+
+> **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/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-comments.md b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-comments.md
new file mode 100644
index 000000000..43104dbb6
--- /dev/null
+++ b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-comments.md
@@ -0,0 +1,71 @@
+Comments {#language.syntax.comments}
+========
+
+Template comments are surrounded by asterisks, and that is surrounded by
+the [delimiter](#variable.left.delimiter) tags like so:
+
+::: {.informalexample}
+
+ {* this is a comment *}
+
+
+:::
+
+Smarty comments are NOT displayed in the final output of the template,
+unlike `<!-- HTML comments -->`. These are useful for making internal
+notes in the templates which no one will see ;-)
+
+
+ {* I am a Smarty comment, I don't exist in the compiled output *}
+ <html>
+ <head>
+ <title>{$title}</title>
+ </head>
+ <body>
+
+ {* another single line smarty comment *}
+ <!-- HTML comment that is sent to the browser -->
+
+ {* this multiline smarty
+ comment is
+ not sent to browser
+ *}
+
+ {*********************************************************
+ Multi line comment block with credits block
+ @ author: bg@example.com
+ @ maintainer: support@example.com
+ @ para: var that sets block style
+ @ css: the style output
+ **********************************************************}
+
+ {* The header file with the main logo and stuff *}
+ {include file='header.tpl'}
+
+
+ {* Dev note: the $includeFile var is assigned in foo.php script *}
+ <!-- Displays main content block -->
+ {include file=$includeFile}
+
+ {* this <select> block is redundant *}
+ {*
+ <select name="company">
+ {html_options options=$vals selected=$selected_id}
+ </select>
+ *}
+
+ <!-- Show header from affiliate is disabled -->
+ {* $affiliate|upper *}
+
+ {* you cannot nest comments *}
+ {*
+ <select name="company">
+ {* <option value="0">-- none -- </option> *}
+ {html_options options=$vals selected=$selected_id}
+ </select>
+ *}
+
+ </body>
+ </html>
+
+
diff --git a/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-functions.md b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-functions.md
new file mode 100644
index 000000000..9c8c94049
--- /dev/null
+++ b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-functions.md
@@ -0,0 +1,40 @@
+Functions {#language.syntax.functions}
+=========
+
+Every Smarty tag either prints a [variable](#language.variables) or
+invokes some sort of function. These are processed and displayed by
+enclosing the function and its [attributes](#language.syntax.attributes)
+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>
+ {else}
+ hi, {$name}
+ {/if}
+
+ {include file="footer.tpl"}
+
+
+
+- Both [built-in functions](#language.builtin.functions) and [custom
+ functions](#language.custom.functions) have the same syntax within
+ templates.
+
+- Built-in functions are the **inner** workings of Smarty, such as
+ [`{if}`](#language.function.if),
+ [`{section}`](#language.function.section) and
+ [`{strip}`](#language.function.strip). There should be no need to
+ change or modify them.
+
+- Custom functions are **additional** functions implemented via
+ [plugins](#plugins). They can be modified to your liking, or you can
+ create new ones. [`{html_options}`](#language.function.html.options)
+ is an example of a custom function.
+
+See also [`registerPlugin()`](#api.register.plugin)
diff --git a/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-quotes.md b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-quotes.md
new file mode 100644
index 000000000..6fe185c97
--- /dev/null
+++ b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-quotes.md
@@ -0,0 +1,61 @@
+Embedding Vars in Double Quotes {#language.syntax.quotes}
+===============================
+
+- Smarty will recognize [assigned](#api.assign)
+ [variables](#language.syntax.variables) embedded in \"double
+ quotes\" so long as the variable name contains only numbers, letters
+ and under\_scores. See [naming](&url.php-manual;language.variables)
+ for more detail.
+
+- With any other characters, for example a period(.) or
+ `$object->reference`, then the variable must be surrounded by
+ `` `backticks` ``.
+
+- In addition Smarty3 does allow embedded Smarty tags in double quoted
+ strings. This is useful if you want to include variables with
+ modifiers, plugin or PHP function results.
+
+<!-- -->
+
+
+ {func var="test $foo test"} // sees $foo
+ {func var="test $foo_bar test"} // sees $foo_bar
+ {func var="test `$foo[0]` test"} // sees $foo[0]
+ {func var="test `$foo[bar]` test"} // sees $foo[bar]
+ {func var="test $foo.bar test"} // sees $foo (not $foo.bar)
+ {func var="test `$foo.bar` test"} // sees $foo.bar
+ {func var="test `$foo.bar` test"|escape} // modifiers outside quotes!
+ {func var="test {$foo|escape} test"} // modifiers inside quotes!
+ {func var="test {time()} test"} // PHP function result
+ {func var="test {counter} test"} // plugin result
+ {func var="variable foo is {if !$foo}not {/if} defined"} // Smarty block function
+
+
+
+
+ {* will replace $tpl_name with value *}
+ {include file="subdir/$tpl_name.tpl"}
+
+ {* does NOT replace $tpl_name *}
+ {include file='subdir/$tpl_name.tpl'} // vars require double quotes!
+
+ {* must have backticks as it contains a dot "." *}
+ {cycle values="one,two,`$smarty.config.myval`"}
+
+ {* must have backticks as it contains a dot "." *}
+ {include file="`$module.contact`.tpl"}
+
+ {* can use variable with dot syntax *}
+ {include file="`$module.$view`.tpl"}
+
+
+
+> **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.
+
+See also [`escape`](#language.modifier.escape).
diff --git a/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-variables.md b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-variables.md
new file mode 100644
index 000000000..671ad8bb8
--- /dev/null
+++ b/vendor/smarty/smarty/docs/designers/language-basic-syntax/language-syntax-variables.md
@@ -0,0 +1,111 @@
+Variables {#language.syntax.variables}
+=========
+
+Template variables start with the \$dollar sign. They can contain
+numbers, letters and underscores, much like a [PHP
+variable](&url.php-manual;language.variables). You can reference arrays
+by index numerically or non-numerically. Also reference object
+properties and methods.
+
+[Config file variables](#language.config.variables) are an exception to
+the \$dollar syntax and are instead referenced with surrounding
+\#hashmarks\#, or via the
+[`$smarty.config`](#language.variables.smarty.config) variable.
+
+
+ {$foo} <-- displaying a simple variable (non array/object)
+ {$foo[4]} <-- display the 5th element of a zero-indexed array
+ {$foo.bar} <-- display the "bar" key value of an array, similar to PHP $foo['bar']
+ {$foo.$bar} <-- display variable key value of an array, similar to PHP $foo[$bar]
+ {$foo->bar} <-- display the object property "bar"
+ {$foo->bar()} <-- display the return value of object method "bar"
+ {#foo#} <-- display the config file variable "foo"
+ {$smarty.config.foo} <-- synonym for {#foo#}
+ {$foo[bar]} <-- syntax only valid in a section loop, see {section}
+ {assign var=foo value='baa'}{$foo} <-- displays "baa", see {assign}
+
+ Many other combinations are allowed
+
+ {$foo.bar.baz}
+ {$foo.$bar.$baz}
+ {$foo[4].baz}
+ {$foo[4].$baz}
+ {$foo.bar.baz[4]}
+ {$foo->bar($baz,2,$bar)} <-- passing parameters
+ {"foo"} <-- static values are allowed
+
+ {* display the server variable "SERVER_NAME" ($_SERVER['SERVER_NAME'])*}
+ {$smarty.server.SERVER_NAME}
+
+ Math and embedding tags:
+
+ {$x+$y} // will output the sum of x and y.
+ {assign var=foo value=$x+$y} // in attributes
+ {$foo[$x+3]} // as array index
+ {$foo={counter}+3} // tags within tags
+ {$foo="this is message {counter}"} // tags within double quoted strings
+
+ Defining Arrays:
+
+ {assign var=foo value=[1,2,3]}
+ {assign var=foo value=['y'=>'yellow','b'=>'blue']}
+ {assign var=foo value=[1,[9,8],3]} // can be nested
+
+ Short variable assignment:
+
+ {$foo=$bar+2}
+ {$foo = strlen($bar)} // function in assignment
+ {$foo = myfunct( ($x+$y)*3 )} // as function parameter
+ {$foo.bar=1} // assign to specific array element
+ {$foo.bar.baz=1}
+ {$foo[]=1} // appending to an array
+
+ Smarty "dot" syntax (note: embedded {} are used to address ambiguities):
+
+ {$foo.a.b.c} => $foo['a']['b']['c']
+ {$foo.a.$b.c} => $foo['a'][$b]['c'] // with variable index
+ {$foo.a.{$b+4}.c} => $foo['a'][$b+4]['c'] // with expression as index
+ {$foo.a.{$b.c}} => $foo['a'][$b['c']] // with nested index
+
+ PHP-like syntax, alternative to "dot" syntax:
+
+ {$foo[1]} // normal access
+ {$foo['bar']}
+ {$foo['bar'][1]}
+ {$foo[$x+$x]} // index may contain any expression
+ {$foo[$bar[1]]} // nested index
+ {$foo[section_name]} // smarty {section} access, not array access!
+
+ Variable variables:
+
+ $foo // normal variable
+ $foo_{$bar} // variable name containing other variable
+ $foo_{$x+$y} // variable name containing expressions
+ $foo_{$bar}_buh_{$blar} // variable name with multiple segments
+ {$foo_{$x}} // will output the variable $foo_1 if $x has a value of 1.
+
+ Object chaining:
+
+ {$object->method1($x)->method2($y)}
+
+ Direct PHP function access:
+
+ {time()}
+
+
+
+
+> **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.
+
+Request variables such as `$_GET`, `$_SESSION`, etc are available via
+the reserved [`$smarty`](#language.variables.smarty) variable.
+
+See also [`$smarty`](#language.variables.smarty), [config
+variables](#language.config.variables)
+[`{assign}`](#language.function.assign) and [`assign()`](#api.assign).