From 9d92dc16131ed920f02f2619b8254e6ab3327a33 Mon Sep 17 00:00:00 2001 From: yannick Date: Tue, 10 May 2005 20:54:42 +0000 Subject: [PATCH] * some wz * no tab * add Cdata section --- .../language-function-capture.xml | 148 +++++------ .../language-function-include.xml | 205 ++++++++------- .../language-function-insert.xml | 238 +++++++++--------- .../language-function-literal.xml | 65 ++--- .../language-function-php.xml | 44 ++-- .../language-function-strip.xml | 95 +++---- 6 files changed, 412 insertions(+), 383 deletions(-) diff --git a/docs/en/designers/language-builtin-functions/language-function-capture.xml b/docs/en/designers/language-builtin-functions/language-function-capture.xml index 204cc75e..99978fdf 100644 --- a/docs/en/designers/language-builtin-functions/language-function-capture.xml +++ b/docs/en/designers/language-builtin-functions/language-function-capture.xml @@ -1,87 +1,87 @@ - - capture - - - - - - - - - - Attribute Name - Type - Required - Default - Description - - - - - name - string - no - default - The name of the captured block - - - assign - string - No - n/a - The variable name where to assign the captured output to - - - - - - capture is used to collect the output of the template into a - variable instead of displaying it. Any content between {capture - name="foo"} and {/capture} is collected into the variable specified - in the name attribute. The captured content can be used in the - template from the special variable $smarty.capture.foo where foo is - the value passed in the name attribute. If you do not supply a name - attribute, then "default" will be used. All {capture} commands must - be paired with {/capture}. You can nest capture commands. - - - Technical Note - - Smarty 1.4.0 - 1.4.4 placed the captured content into the - variable named $return. As of 1.4.5, this behavior was changed to use - the name attribute, so update your templates accordingly. - - - - - Be careful when capturing insert output. If - you have caching turned on and you have insert - commands that you expect to run within cached content, do not - capture this content. - - - - - capturing template content - + + capture + + + + + + + + + + Attribute Name + Type + Required + Default + Description + + + + + name + string + no + default + The name of the captured block + + + assign + string + No + n/a + The variable name where to assign the captured output to + + + + + + capture is used to collect the output of the template into a + variable instead of displaying it. Any content between {capture + name="foo"} and {/capture} is collected into the variable specified + in the name attribute. The captured content can be used in the + template from the special variable $smarty.capture.foo where foo is + the value passed in the name attribute. If you do not supply a name + attribute, then "default" will be used. All {capture} commands must + be paired with {/capture}. You can nest capture commands. + + + Technical Note + + Smarty 1.4.0 - 1.4.4 placed the captured content into the + variable named $return. As of 1.4.5, this behavior was changed to use + the name attribute, so update your templates accordingly. + + + + + Be careful when capturing insert output. If + you have caching turned on and you have insert + commands that you expect to run within cached content, do not + capture this content. + + + + + capturing template content + - - {$smarty.capture.banner} - - + + + {$smarty.capture.banner} + + {/if} ]]> - - - + + + - - include - - - - - - - - - - Attribute Name - Type - Required - Default - Description - - - - - file - string - Yes - n/a - The name of the template file to include - - - assign - string - No - n/a - The name of the variable that the output of - include will be assigned to - - - [var ...] - [var type] - No - n/a - variable to pass local to template - - - - - - Include tags are used for including other templates in the current - template. Any variables available in the current template are also - available within the included template. The include tag must have - the attribute "file", which contains the template resource path. - - - You can optionally pass the assign attribute, - which will specify a template variable name that the output of - include will be assigned to instead of - displayed. - - -function include - -{include file="header.tpl"} + + include + + + + + + + + + + Attribute Name + Type + Required + Default + Description + + + + + file + string + Yes + n/a + The name of the template file to include + + + assign + string + No + n/a + The name of the variable that the output of + include will be assigned to + + + [var ...] + [var type] + No + n/a + variable to pass local to template + + + + + + Include tags are used for including other templates in the current + template. Any variables available in the current template are also + available within the included template. The include tag must have + the attribute "file", which contains the template resource path. + + + You can optionally pass the assign attribute, + which will specify a template variable name that the output of + include will be assigned to instead of + displayed. + + + function include + + - - - You can also pass variables to included templates as attributes. - Any variables explicitly passed to an included template as - attributes are only available within the scope of the included - file. Attribute variables override current template variables, in - the case they are named alike. - - -function include passing variables - -{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"} + {include file="footer.tpl"} +]]> + + + + You can also pass variables to included templates as attributes. + Any variables explicitly passed to an included template as + attributes are only available within the scope of the included + file. Attribute variables override current template variables, in + the case they are named alike. + + + function include passing variables + + - - - Use the syntax for template resources to - include files outside of the $template_dir directory. - - -function include template resource examples - -{* absolute filepath *} -{include file="/usr/local/include/templates/header.tpl"} + {include file="footer.tpl" logo="http://my.example.com/logo.gif"} +]]> + + + + Use the syntax for template resources to + include files outside of the $template_dir directory. + + + function include template resource examples + + - -See also {include_php}, {php} Template Resources and Componentized Templates + {* include from template resource named "db" *} + {include file="db:header.tpl"} +]]> + + + + See also + {include_php}, + {php}, + Template Resources and + Componentized Templates. + - - insert - - - - - - - - - - Attribute Name - Type - Required - Default - Description - - - - - name - string - Yes - n/a - The name of the insert function (insert_name) - - - assign - string - No - n/a - The name of the template variable the output will - be assigned to - - - script - string - No - n/a - The name of the php script that is included before - the insert function is called - - - [var ...] - [var type] - No - n/a - variable to pass to insert function - - - - - - Insert tags work much like include tags, except that insert tags - are not cached when you have template caching enabled. They will be - executed on every invocation of the template. - - - 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), and needs to - call a function to get the banner contents. - - -function insert - -{* example of fetching a banner *} -{insert name="getBanner" lid=#banner_location_id# sid=#site_id#} - - - 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 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. When security is - enabled, the script must reside in $trusted_dir. - - - 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. - - - Technical Note - - It is possible to have portions of the template not - cached. If you have caching - 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. - - - - - - literal - - Literal tags allow a block of data to be taken literally. This is typically - used around javascript or stylesheet blocks where curly braces would - interfere with the template delimiter syntax. Anything within - {literal}{/literal} tags is not interpreted, but displayed as-is. If you - need template tags embedded in your literal block, consider using {ldelim}{rdelim} to escape the - individual delimiters instead. - - - literal tags - + + literal + + Literal tags allow a block of data to be taken literally. This is typically + used around javascript or stylesheet blocks where curly braces would + interfere with the template delimiter syntax. Anything within + {literal}{/literal} tags is not interpreted, but displayed as-is. If you + need template tags embedded in your literal block, consider using {ldelim}{rdelim} to escape the + individual delimiters instead. + + + literal tags + + + {/literal} ]]> - - - See also Escaping Smarty Parsing - + + + + See also + Escaping Smarty Parsing. + + - - php - - php tags allow php to be embedded directly into the template. They - will not be escaped, regardless of the $php_handling setting. This - is for advanced users only, not normally needed. - - -php tags - -{php} - // including a php script directly - // from the template. - include("/path/to/display_weather.php"); -{/php} - - See also {include_php}, {include} and Componentized Templates + + php + + php tags allow php to be embedded directly into the template. They + will not be escaped, regardless of the $php_handling setting. This + is for advanced users only, not normally needed. + + + php tags + + + + + + See also + {include_php}, + {include} and + Componentized Templates. + - - strip - - Many times web designers run into the issue where white space and - carriage returns affect the output of the rendered HTML (browser - "features"), so you must run all your tags together in the template - to get the desired results. This usually ends up in unreadable or - unmanageable templates. - - - Anything within {strip}{/strip} tags in Smarty are stripped of the - extra spaces or carriage returns at the beginnings and ends of the - lines before they are displayed. This way you can keep your - templates readable, and not worry about extra white space causing - problems. - - - Technical Note - - {strip}{/strip} does not affect the contents of template variables. - See the strip modifier - function. - - - -strip tags - + + strip + + Many times web designers run into the issue where white space and + carriage returns affect the output of the rendered HTML (browser + "features"), so you must run all your tags together in the template + to get the desired results. This usually ends up in unreadable or + unmanageable templates. + + + Anything within {strip}{/strip} tags in Smarty are stripped of the + extra spaces or carriage returns at the beginnings and ends of the + lines before they are displayed. This way you can keep your + templates readable, and not worry about extra white space causing + problems. + + + Technical Note + + {strip}{/strip} does not affect the contents of template variables. + See the strip modifier + function. + + + + strip tags + - - - - This is a test - - - + + + + This is a test + + + {/strip} - - -OUTPUT: - +]]> + + + The above example will output: + + +This is a test ]]> - - - - Notice that in the above example, all the lines begin and end - with HTML tags. Be aware that all the lines are run together. - If you have plain text at the beginning or end of any line, - they will be run together, and may not be desired results. - + + + + Notice that in the above example, all the lines begin and end + with HTML tags. Be aware that all the lines are run together. + If you have plain text at the beginning or end of any line, + they will be run together, and may not be desired results. +