<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://php.apsique.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Php y otras yerbas - De Plantillas y demases: el enfoque KISS - Comentarios</title>
 <link>http://php.apsique.com/contenido/curso_php/enfoque_kiss</link>
 <description>Comentarios para &quot;De Plantillas y demases: el enfoque KISS&quot;</description>
 <language>es</language>
<item>
 <title>quisiera saber mas sobre las</title>
 <link>http://php.apsique.com/contenido/curso_php/enfoque_kiss#comment-77637</link>
 <description>&lt;p&gt;quisiera saber mas sobre las plantillas php.&lt;br /&gt;
¿como se crean?&lt;br /&gt;
¿para que nos sirven?&lt;br /&gt;
¿como se modifican?&lt;br /&gt;
etc...&lt;/p&gt;
</description>
 <pubDate>Mon, 03 Mar 2008 09:06:09 -0800</pubDate>
 <dc:creator>NEFTALI BIÑUELO</dc:creator>
 <guid isPermaLink="false">comment 77637 at http://php.apsique.com</guid>
</item>
<item>
 <title>Lo mismo, pero bien explicado</title>
 <link>http://php.apsique.com/contenido/curso_php/enfoque_kiss#comment-923</link>
 <description>&lt;p&gt;Je. Me gusta ver que cuando gente más lista que yo llega a las mismas conclusiones.&lt;br /&gt;
http://www.massassi.com/php/articles/template_engines/&lt;br /&gt;
Fijense que el código de la clase Template es casi el mismo, sólo que yo prefiero, por flojera, utilizar un extract para evitar el uso masivo de set(). Eso sí, el uso de esta función permite reconocer más fácilmente las variables involucradas. Ahora, no cuesta nada tener la plantilla y el código php abierto para ver cual variable hace que cosa y, mejor aún, crear un comentario al inicio que diga cual es la función de cada variable.&lt;/p&gt;
</description>
 <pubDate>Thu, 07 Apr 2005 22:14:12 -0700</pubDate>
 <dc:creator>clbustos</dc:creator>
 <guid isPermaLink="false">comment 923 at http://php.apsique.com</guid>
</item>
<item>
 <title>Genial..pero (2)</title>
 <link>http://php.apsique.com/contenido/curso_php/enfoque_kiss#comment-922</link>
 <description>&lt;p&gt;Estoy en general de acuerdo contigo, pero hay dos casos particulares en que un sistema como este no sería adecuado:&lt;br /&gt;
1) Diseñadores que trabajan exclusivamente con WYSWYG&lt;br /&gt;
2) Plantillas editables por usuarios.&lt;br /&gt;
En ambos casos, es necesario evitar a toda costa ocupar código PHP directo, en el primero por la congénita inhabilidad de los diseñadores para entender algo que huela a código y, en la segunda, por los posibles escapes de seguridad. En este tipo de situaciones, recomendaría un sistema basado en expresiones regulares, tipo Template_IT.&lt;/p&gt;
</description>
 <pubDate>Thu, 07 Apr 2005 15:08:20 -0700</pubDate>
 <dc:creator>clbustos</dc:creator>
 <guid isPermaLink="false">comment 922 at http://php.apsique.com</guid>
</item>
<item>
 <title>Genial..pero</title>
 <link>http://php.apsique.com/contenido/curso_php/enfoque_kiss#comment-920</link>
 <description>&lt;p&gt;El enfoque que propones lo he visto varias veces, empezando con el Savant y otros.&lt;/p&gt;
&lt;p&gt;Sin embargo lo único que veo de ventaja en una maquinaria de templates más &quot;robusta&quot;, es la posibilidad de abstraer varios elementos, principalmente de formularios HTML a componentes que se pueden configurar, más o menos como lo que tiene ASP.NET.&lt;/p&gt;
&lt;p&gt;El sistema WACT funciona así y me parece que mientras se pueda mantener clara la separación entre lógica de negocio y de presentación, está bien.&lt;/p&gt;
</description>
 <pubDate>Wed, 06 Apr 2005 21:37:48 -0700</pubDate>
 <dc:creator>Manolo Gómez</dc:creator>
 <guid isPermaLink="false">comment 920 at http://php.apsique.com</guid>
</item>
<item>
 <title>Xipe</title>
 <link>http://php.apsique.com/contenido/curso_php/enfoque_kiss#comment-909</link>
 <description>&lt;p&gt;Je, que bueno que te sirva. Si tu sistema es simple y quieres algo rápido, ocupa esta forma.&lt;br /&gt;
Me leíste la mente. Después de tratar IT y Sigma, me iré con Xipe y Savant. Smarty lo dejo para el final, no por lo bueno, sino por que quiero alejar ese momento de mi mente....&lt;/p&gt;
</description>
 <pubDate>Sun, 03 Apr 2005 23:27:03 -0700</pubDate>
 <dc:creator>clbustos</dc:creator>
 <guid isPermaLink="false">comment 909 at http://php.apsique.com</guid>
</item>
<item>
 <title>Tienes Razon</title>
 <link>http://php.apsique.com/contenido/curso_php/enfoque_kiss#comment-908</link>
 <description>&lt;p&gt;Empece a quedarme ciego tienes toda la razon.&lt;br /&gt;
Voy a usar este tipo de plantilla para un sistema de mailing que hare.&lt;br /&gt;
Ah ojala mas adelante puedas publicar algo sobre Xipe quizas un pequeño manual como este.&lt;/p&gt;
&lt;p&gt;Saludos&lt;/p&gt;
</description>
 <pubDate>Sun, 03 Apr 2005 09:38:21 -0700</pubDate>
 <dc:creator>Perijilillo Desconocido</dc:creator>
 <guid isPermaLink="false">comment 908 at http://php.apsique.com</guid>
</item>
<item>
 <title>Cabecera</title>
 <link>http://php.apsique.com/contenido/curso_php/enfoque_kiss#comment-907</link>
 <description>&lt;p&gt;Perijilillo: Gracias. Sobre la cabecera, no debería aparecer en el cuerpo, porque es precisamente la cabecera. Ve si el título de la página dice &#039;[a-la letra a][b-la letra b][c-la letra c]&#039;&lt;br /&gt;
Jesús: A principios del año pasado hice un pequeño curso en la UBB. De los apuntes de clases hice el curso. Ahora lo estoy continuando....&lt;/p&gt;
</description>
 <pubDate>Sat, 02 Apr 2005 21:48:43 -0800</pubDate>
 <dc:creator>clbustos</dc:creator>
 <guid isPermaLink="false">comment 907 at http://php.apsique.com</guid>
</item>
<item>
 <title>nunca lo supe</title>
 <link>http://php.apsique.com/contenido/curso_php/enfoque_kiss#comment-906</link>
 <description>&lt;p&gt;cuando iniciaste estos cursos que no me dí cuenta?? :&#039;(&lt;/p&gt;
</description>
 <pubDate>Sat, 02 Apr 2005 15:21:41 -0800</pubDate>
 <dc:creator>Jesus Sanchez</dc:creator>
 <guid isPermaLink="false">comment 906 at http://php.apsique.com</guid>
</item>
<item>
 <title>Excelente</title>
 <link>http://php.apsique.com/contenido/curso_php/enfoque_kiss#comment-905</link>
 <description>&lt;p&gt;Me parece mu buena y un codigo bastante limpio.&lt;br /&gt;
encontre un pequeño error, por algun motivo no me funciona la cabecera, no imprime.&lt;/p&gt;
</description>
 <pubDate>Sat, 02 Apr 2005 11:17:29 -0800</pubDate>
 <dc:creator>Perijilillo Desconocido</dc:creator>
 <guid isPermaLink="false">comment 905 at http://php.apsique.com</guid>
</item>
<item>
 <title>De Plantillas y demases: el enfoque KISS</title>
 <link>http://php.apsique.com/contenido/curso_php/enfoque_kiss</link>
 <description>&lt;p&gt;Un viejo tema en todo foro de discusión que se precie de PHP es el uso de plantillas. En la &lt;a href=&#039;http://php.apsique.com/node/20&#039;&gt;sección del curso de PHP dedicado a la separación del contenido y del diseño &lt;/a&gt; me di la lata de explicar el porque del uso de plantillas, las ventajas de separar la presentación del contenido y hasta di un ejemplo completo.&lt;/p&gt;
&lt;p&gt;Como el tiempo pasa, cada vez me doy cuenta de la importancia de saber ocupar el nivel de complejidad estrictamente necesario para cada proyecto. Me gusta mucho el &lt;a href=&#039;http://en.wikipedia.org/wiki/KISS_principle&#039;&gt;principio KISS&lt;/a&gt; de los gringos, que sería algo así como &quot;Manténlo simple, estúpido!&quot;. Por algo mi odio inveterado a &lt;a href=&#039;http://smarty.php.net/&#039;&gt;Smarty&lt;/a&gt;, el mayor monstruo en lo relacionado a plantillas que he podido ver. Pero ya habrá tiempo de explicar porque es tan malo :P &lt;/p&gt;
&lt;p&gt;¿A que iba todo esto? A que si hacemos memoria, PHP ES UN LENGUAJE DE PLANTILLAS. Nació, precisamente, para ser usado como un lenguaje embebido dentro de páginas HTML. No reniego del uso de plantillas decentes (a mi me gusta particularmente &lt;a href=&#039;http://pear.php.net/package/HTML_Template_Xipe&#039;&gt;Xipe&lt;/a&gt;), pero hay que saber cuando ocupar que tipo de plantillas en que momento.
A grandes rasgos, existen dos tipos de sistemas, aparte del propio PHP. El primer tipo es el basado en la &lt;b&gt;compilación de php&lt;/b&gt;, en el cual se genera código en forma dinámica a partir de la plantilla  básica; tiene la ventaja de que es muy rápido, ya que al fin y al cabo, utiliza todos los recursos de php como sistema de plantillas, pero es susceptible a exploits si se logra manipular la generación de código para producir algún tipo de ataque. El segundo tipo está basado en el procesamiento de la plantilla por &lt;strong&gt;expresiones regulares&lt;/strong&gt;; si bien es lento, ya que implica un procesamiento intento de cadenas, tiene la gran ventaja de ser casi invulnerable a cualquier tipo de ataque.&lt;/p&gt;
&lt;p&gt;Ahora, en un proyecto simple, ¿para que calentarse la cabeza? Ocupemos el viejo &lt;code&gt;include&lt;/code&gt;, dentro de una clase que nos permita mayor comodidad.&lt;/p&gt;
&lt;p&gt;Observen el siguiente código: &lt;/p&gt;
&lt;p&gt;&lt;b&gt;Plantilla.class.php&lt;/b&gt;&lt;/p&gt;
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-inlinetags&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;Plantilla&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;        &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sRoot&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;        &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;Plantilla&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sRoot&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/li&gt;
&lt;li&gt;&amp;nbsp;        &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;substr&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sRoot&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;, -&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; == &lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sRoot&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;substr&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sRoot&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;, -&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sRoot&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;sRoot&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sRoot&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;        &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;        &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;obtener&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sFile&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$aVars&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/li&gt;
&lt;li&gt;&amp;nbsp;        &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;extract&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$aVars&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;ob_start&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sPath&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;sRoot&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sFile&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;file_exists&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sPath&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;trigger_error&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;No existe la plantilla &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sFile&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;E_USER_ERROR&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sPath&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sOut&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;ob_get_contents&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;ob_end_clean&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sOut&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;        &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-inlinetags&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;¿Ven? Nada más simple. El objeto plantilla tiene como única propiedad el directorio base de las carpetas y con el método &lt;code&gt;obtener&lt;/code&gt;, obtenemos el texto de la plantilla, el cual puede tener todo el php que queramos. &lt;/p&gt;
&lt;p&gt;Ahora, las 2 plantillas de ejemplo&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Cabecera.tpl&lt;/b&gt;&lt;/p&gt;
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;php&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;foreach&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;($&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;$x) { echo &#039;[&#039;.$i.&#039;-&#039;.$x.&#039;]&#039;; } ?&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;cuerpo.tpl&lt;/b&gt;&lt;/p&gt;
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;php&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;foreach&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;($&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;) { &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=$&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; } &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Como pueden apreciar, pido dos arreglos, uno llamado $a y el otro $b. Démosle valores:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;test.php&lt;/b&gt;&lt;/p&gt;
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-inlinetags&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;include_once&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;Plantilla.class.php&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$p&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;Plantilla&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;./&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$a&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;la letra a&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;la letra b&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;la letra c&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$b&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;primer item&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;segundo item&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;tercer item&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$texto2&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$p&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;obtener&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;cuerpo.tpl&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;compact&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$texto1&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$p&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;obtener&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;cabecera.tpl&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;compact&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$texto1&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$texto2&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-inlinetags&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Ven? El mínimo código necesario, y tenemos completamente separados el código de las plantillas. Ok, sé que si pasan una variable errónea les van a aparecer Notices o incluso Warnings hasta por las orejas, pero si están armando un pequeño foro, ¿para que quieren algo más complejo?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;KISS, baby, KISS&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;En las siguientes sesiones, veremos otros sistemas de plantillas para las cosas que sean más grandes que un FAQ&lt;/p&gt;
</description>
 <comments>http://php.apsique.com/contenido/curso_php/enfoque_kiss#comments</comments>
 <category domain="http://php.apsique.com/lenguajes/php/curso_avanzado">Curso de Php Avanzado</category>
 <category domain="http://php.apsique.com/categoria/temas_generales/programacion">Programación</category>
 <category domain="http://php.apsique.com/categoria/busquedas_comunes/kiss">kiss</category>
 <category domain="http://php.apsique.com/categoria/busquedas_comunes/php">php</category>
 <category domain="http://php.apsique.com/categoria/busquedas_comunes/php_plantilla">php como plantilla</category>
 <category domain="http://php.apsique.com/categoria/busquedas_comunes/plantillas">plantillas</category>
 <enclosure url="http://php.apsique.com/files/plantilla_simple.tgz" length="804" type="application/x-gtar" />
 <pubDate>Sat, 02 Apr 2005 00:56:11 -0800</pubDate>
 <dc:creator>clbustos</dc:creator>
 <guid isPermaLink="false">418 at http://php.apsique.com</guid>
</item>
</channel>
</rss>
