theneiam/twade

Seotoaster 2.x 的视图引擎插件,为系统带来 Twig 和 Blade 的功能

dev-master 2014-08-18 16:24 UTC

This package is not auto-updated.

Last update: 2024-09-24 02:52:34 UTC


README

Code Climate Latest Stable Version Total Downloads Latest Unstable Version License

TwAde 是 SEO Toaster CMS 的插件

使用 TwAde,可以非常容易地开始使用流行的模板引擎,如 TwigBladeMustache,在你的插件中,甚至在 SEO Toaster 的核心中!

安装

手动

  1. 从 GitHub 下载或克隆插件到你的 Seotoaster 插件目录
  2. 进入 twade 目录并运行 composer install 命令
  3. Disco

通过 Composer

$ curl -s https://getcomposer.org/installer | php
  • 现在,更改你的 composer.json 文件
{
    "require": {
        "theneiam/twade": "dev-master"
    }
}
  • 然后进行安装
$ composer install
  • Disco!

使用说明

如何使用 TwAde 的模板引擎功能的示例。 你可以在 Twade.php 中找到一些示例

// Define config options.

// Twig engine options. It supports Twig extensions now!
$options = array(
    'engine'        => 'Twig',
    'templatesPath' => __DIR__ . '/example/twig/',
    'cache'         => __DIR__ . '/../../cache/',
    'extensions'    => array(
        'Twig_Extensions_Extension_I18n' // The i18n extension only works if the PHP gettext extension is enabled.
    )
);

// Blade engine options
$options = array(
    'engine'        => 'Blade',
    'templatesPath' => __DIR__ . '/example/blade/',
    'cache'         => __DIR__ . '/../../cache/'
);

// Mustache engine options. Yeah! Twade supports mustache from now on!
$options = array(
    'engine'        => 'Mustache',
    'templatesPath' => __DIR__ . '/example/mustache',
    'cache'         => __DIR__ . '/../../cache/'
);

// Now, let's create a view and enjoy
// Create view
$view = \Twade\Engine\Factory::create($options);

// Assign some vars
$view->welcome = 'Welcome to the TwAde plugin!';

// Disco!
echo $this->_view->render('welcome');