资源说明:Stencil 是一个 CodeIgniter 的模板引擎,通过简单可靠的方式来渲染 HTML 页面。
控制器:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->stencil->layout('home_layout');
$this->stencil->slice('header');
$this->stencil->slice('footer');
}
public function index()
{
$this->stencil->title('Home Page');
$this->stencil->js('some-plugin');
$this->stencil->js('home-slider');
$this->stencil->css('home-slider');
$this->stencil->meta(array(
'author' => 'Nicholas Cerminara',
'description' => 'This is the home page of my website!',
'keywords' => 'stencil, example, fun stuff'
));
$data['welcome_message'] = 'Welcome to my website using Stencil!';
$this->stencil->paint('home_view', $data);
}
}
/* End of file home.php */
/* Location: ./application/controllers/home.php */
模板:
<html>
<head>
<!-- robot speak -->
<meta charset="utf-8">
<title><?php echo $title; ?> | My Stencil Website</title>
<?php echo chrome_frame(); ?>
<?php echo view_port(); ?>
<?php echo apple_mobile('black-translucent'); ?>
<?php echo $meta; ?><!-- //loads data from $this->stencil->meta($args) in controller -->
<!-- icons and icons and icons and icons and icons -->
<?php echo favicons(); ?>
<!-- crayons and paint -->
<?php echo add_css(array('bootstrap', 'style')); ?>
<?php echo $css; ?><!-- //loads data from $this->stencil->css($args) in controller -->
<!-- magical wizardry -->
<?php echo jquery('1.9.1'); ?>
<?php echo shiv(); ?>
<?php echo add_js(array('bootstrap.min', 'scripts')); ?>
<?php echo $js; ?><!-- //loads page specific $this->stencil->js($args) from Controller (see docs) -->
</head>
<!-- $body_class will always be the class name -->
<body class="<?php echo $body_class; ?>">
<header>
<?php echo $header; ?>
</header>
<?php echo $content; ?><!-- This loads home_view -->
</body>
</html>
标签:Stencil
<?php echo $welcome_message; ?>
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。