Files
smarty/docs/pt_BR/programmers/plugins/plugins-compiler-functions.xml

82 lines
2.8 KiB
XML
Raw Normal View History

2004-04-13 11:47:32 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="plugins.compiler.functions"><title>Fun<EFBFBD><EFBFBD>es Compiladoras</title>
<para>
Fun<75><6E>es compiladoras s<> s<>o chamadas durante a compila<6C><61>o do template.
Elas s<>o <20>teis para inje<6A><65>o de c<>digo PHP ou conte<74>do est<73>tico time-sensitive
dentro do template. Se h<> ambos, uma fun<75><6E>o
compiladora e uma fun<75><6E>o customiz<69>vel
registrada sob o mesmo nome, a fun<75><6E>o compiladora tem preced<65>ncia.
</para>
<funcsynopsis>
<funcprototype>
<funcdef>mixed <function>smarty_compiler_<replaceable>name</replaceable></function></funcdef>
<paramdef>string <parameter>$tag_arg</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<20> fun<75><6E>o compiladora s<>o passados dois par<61>metros:
a tag string de argumento da tag - basicamente, tudo a partir
do nome da fun<75><6E>o at<61> o delimitador de fechamento, e o objeto da Smarty. <20> suposto que retorna o c<>digo PHP
para ser injetado dentro do template compilado.
</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>fun<EFBFBD><EFBFBD>o compiladora simples</title>
<programlisting>
&lt;?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, &amp;$smarty)
{
return "\necho '" . $smarty-&gt;_current_file . " compiled at " . date('Y-m-d H:M'). "';";
}
?&gt;</programlisting>
<para>
Esta fun<75><6E>o pode ser chamada em um template da seguinte forma:
</para>
<programlisting>
{* esta fun<75><6E>o <20> executada somente no tempo de compila<6C><61>o *}
{tplheader}</programlisting>
<para>
O c<>digo PHP resultante no template compilado seria algo assim:
</para>
<programlisting>
&lt;php
echo 'index.tpl compiled at 2002-02-20 20:02';
?&gt;</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
-->