CodeIgniter 模板引擎 Stencil

码农软件 · 软件分类 · 模板引擎 · 2019-08-23 10:58:52

软件介绍

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 */

模板:

<!doctype html>
<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>

    <h1><?php echo $welcome_message; ?></h1>

    <section class="content">
        <?php echo $content; ?><!-- This loads home_view -->
    </section>

    <footer>
        <?php echo $footer; ?>
    </footer>

</body>
</html>

本文地址:https://codercto.com/soft/d/12984.html

科技之巅

科技之巅

麻省理工科技评论 / 人民邮电出版社 / 2016-10-1 / CNY 98.00

《麻省理工科技评论》从2001年开始,每年都会公布“10大突破技术”,即TR10(Technology Review 10),并预测其大规模商业化的潜力,以及对人类生活和社会的重大影响。 这些技术代表了当前世界科技的发展前沿和未来发展方向,集中反映了近年来世界科技发展的新特点和新趋势,将引领面向未来的研究方向。其中许多技术已经走向市场,主导着产业技术的发展,极大地推动了经济社会发展和科技创新......一起来看看 《科技之巅》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

SHA 加密
SHA 加密

SHA 加密工具