Templates

From Nephtali Documentation

Jump to: navigation, search

Templates the same conventions as other features in the Nephtali web framework. The regions in the markup that are overridable within a template are identified by comments. Regions within a template may be overrided by the requested page or other templates (templates are processed in the order they are registered, so the first-registered template is considered the base-template from which the others must build.)

Below is the markup for a base template, a child template, and the markup within the page requested, followed by the final version of the markup after Nepthali's processing:

Contents

Base Template

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<div id="header">
	<h1>The Site Title</h1>
    <p>What a great tagline</p>
</div>
<div id="content">
<!--region:content-->
<!--region:content-->
</div>
<p id="footer">Copyright © 2010 Cool Company, LLC</p>
</body>
</html>

Two Column Template

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<!--region:content-->
<!--region:col1-->
<!--region:col1-->
<!--region:col2-->
<!--region:col2-->
<!--region:content-->
</body>
</html>

Page Markup

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<!--region:col1-->
<p id="col1">Helloooooooooooooooooo</p>
<!--region:col1-->
<!--region:col2-->
<p id="col2">World</p>
<!--region:col2-->
</body>
</html>

Final Output

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Untitled Document</title> 
</head> 
 
<body>  
<div id="header"> 
	<h1>The Site Title</h1> 
    <p>What a great tagline</p> 
</div> 
<div id="content"> 
 
 
<p id="col1">Helloooooooooooooooooo</p> 
 
 
<p id="col2">World</p> 
 
 
</div> 
<p id="footer">Copyright © 2010 Cool Company, LLC</p> 
</body> 
</html>

PHP in Nephtali code-behind file

n\template\register($path = '/home/nephtali/webapps/phpstack/htdocs/tests/test_template.php', $regions = array('header', 'footer', 'content'));
n\template\register($path = '/home/nephtali/webapps/phpstack/htdocs/tests/two_column_template.php', $regions = array('col1','col2'));
Personal tools