Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Im not fan ov additional templating languages (that replace wildcards) instead i like to keep my templates pure php so my vertion of what you have done would be:</p> <p><code>&lt;div id="blah"&gt;&lt;b&gt;&lt;?php echo $username ?&gt;&lt;/b&gt;&lt;?php echo $stuff ?&gt;&lt;...&gt;</code></p> <p><code>echo GetTemplate( 'myTemplate.php', array ( 'username' =&gt; 'Stranger', 'stuff' =&gt; 'Stuff' ) );</code></p> <pre><code>function GetTemplate($templatePath, array $vars = array()) { extract($vars); ob_start(); include($templatePath); return ob_get_clean(); } </code></pre> <p>I alos combine this with helper functions/object->methods as well for example:</p> <p><code>&lt;?php echo link_to($name, $url); ?&gt;</code></p> <pre><code>function link_to($name, $url, array $attributes = array()) { $attributes['href'] = urlencode($url); foreach($attributes as $attrib =&gt; $value) { $attributes[$attrib] = $attrib."=\"$value\""; } return sprintf('&lt;a %s&gt;%s&lt;/a&gt;', implode(" ",$attributes), $name); } </code></pre> <p>I generally apply helpers like these to commonly used tags/structures as well as having a general purpose html tag one that looks something like <code>content_tag($tag, $content, $attributes);</code> This helps me avoid a php echo for tons of attributes for random tags. I obviously dont use it for every html tag i use only for ones where it makes for better readability than a ton of echos.</p> <p>As far as templating engines go i dont really see the benefit as php is templating language. As far as non-programmers/coders they have to leanr the syntax for a loop and a variable any how so i dont see how changing it to wildcards or the {} syntax of smarty adds anything. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload