theneiam/twade

View engine plugin for Seotoaster 2.x, that brings Twig and Blade power to the system

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

This package is not auto-updated.

Last update: 2024-05-07 01:00:09 UTC


README

Code Climate Latest Stable Version Total Downloads Latest Unstable Version License

TwAde is the plugin for the SEO Toaster CMS

With TwAde it is very easy to start using the power of the popular template engines, such as Twig, Blade or Mustache, within your plugins or, even, in the SEO Toaster's core!

INSTALLATION

Manual

  1. Download or clone plugin from GitHub to your Seotoaster plugins directory
  2. Go to the twade directory and run composer install command
  3. Disco

Via Composer

$ curl -s https://getcomposer.org/installer | php
  • Now, change your composer.json
{
    "require": {
        "theneiam/twade": "dev-master"
    }
}
  • And install
$ composer install
  • Disco!

USEAGE

Example of how to use power of the famous template engines with TwAde. you can find some demos in the 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');