Skip to content

Instantly share code, notes, and snippets.

@jonavon
Last active August 29, 2015 14:06
Show Gist options
  • Save jonavon/21f10e47976549728027 to your computer and use it in GitHub Desktop.
Save jonavon/21f10e47976549728027 to your computer and use it in GitHub Desktop.
<!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><?php echo $title; ?></title>
<link rel="shortcut icon" type="image/png" href="favicon.png" />
<link rel="stylesheet" href="./css/reset.css" type="text/css" media="all" />
<link rel="stylesheet" href="./css/text.css" type="text/css" media="all" />
<link rel="stylesheet" href="./css/style.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
<!--[if IE]>
<link rel="stylesheet" href="./css/ie.css" type="text/css" media="screen, projection" />
<![endif]-->
<link rel="script" href="./scripts/javascript.js" type="text/javascript" />
</head>
<body>
<p><?php echo $text; ?></p>
<ul>
<?php foreach($links as $link): ?>
<li><a href="<?php echo $link; ?>" title="A Link"><?php echo $link; ?></li>
<?php endforeach; ?>
</ul>
</body>
</html>
<?php
function apply_template($file,$vars=array(),$include_globals=false){
extract($vars);
if($include_globals){
extract($GLOBALS, EXTR_SKIP);
}
ob_start();
require($file);
$template_html = ob_get_contents();
header('Content-Length: ' . ob_get_length());
ob_end_clean();
return $template_html;
}
$template_vars['title'] = 'Hello World!';
$template_vars['text'] = 'Hello World!';
$template_vars['links'] = array(
'http://www.bigsmoke.us/php-templates/functions',
'http://www.php.net/'
);
$html = apply_template("_main.tpl.php",$template_vars);
echo $html;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment