mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-26 09:51:36 +01:00
banana split
This commit is contained in:
84
docs/ru/programmers/plugins/plugins-compiler-functions.xml
Normal file
84
docs/ru/programmers/plugins/plugins-compiler-functions.xml
Normal file
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.compiler.functions"><title>Compiler Functions</title>
|
||||
<para>
|
||||
Compiler functions are called only during compilation of the template.
|
||||
They are useful for injecting PHP code or time-sensitive static
|
||||
content into the template. If there is both a compiler function and a
|
||||
custom function registered under the same name, the compiler function
|
||||
has precedence.
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>mixed <function>smarty_compiler_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>string <parameter>$tag_arg</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
The compiler function is passed two parameters: the tag argument
|
||||
string - basically, everything from the function name until the ending
|
||||
delimiter, and the Smarty object. It's supposed to return the PHP code
|
||||
to be injected into the compiled template.
|
||||
</para>
|
||||
<para>
|
||||
See also
|
||||
<link linkend="api.register.compiler.function">register_compiler_function()</link>,
|
||||
<link linkend="api.unregister.compiler.function">unregister_compiler_function()</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>simple compiler function</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: compiler.tplheader.php
|
||||
* Type: compiler
|
||||
* Name: tplheader
|
||||
* Purpose: Output header containing the source file name and
|
||||
* the time it was compiled.
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_compiler_tplheader($tag_arg, &$smarty)
|
||||
{
|
||||
return "\necho '" . $smarty->_current_file . " compiled at " . date('Y-m-d H:M'). "';";
|
||||
}
|
||||
?>
|
||||
]]></programlisting>
|
||||
<para>
|
||||
This function can be called from the template as:
|
||||
</para>
|
||||
<programlisting>
|
||||
{* this function gets executed at compile time only *}
|
||||
{tplheader}</programlisting>
|
||||
<para>
|
||||
The resulting PHP code in the compiled template would be something like this:
|
||||
</para>
|
||||
<programlisting>
|
||||
<php
|
||||
echo 'index.tpl compiled at 2002-02-20 20:02';
|
||||
?></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
Reference in New Issue
Block a user