/ Published in: PHP
Based on Jdub7's Pure PHP Template function
http://snipplr.com/view/10797/pure-php-template-function/
Expand |
Embed | Plain Text
<?php foreach ($vars as $key => $var) { } return $template; } 'title' => 'Hello World!', 'text' => 'Hello!', 'link' => 'http://www.bigsmoke.us/php-templates/functions' ); $html = apply_template("_main.tpl",$template_vars); echo $html; #_main.tpl # # #<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" # "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> #<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr"> #<head> # <meta http-equiv="content-type" content="text/html; charset=utf-8" /> # <title>[+title+]</title> # #</head> #<body> # <h1>[+title+]</h1> # <p>[+text+]</p> # <a href="[+link+]">[+link+]</a> #</body> #</html> ?>
Comments
Subscribe to comments
You need to login to post a comment.

Interesting, I think this would be useful to offer my clients simple email templates. It poses some difficulty when using control structures.
Yes, the idea behind the code is to use it to format simple documents without include php statements, like forms or database generated emails.
Thanks for your comments