コード例 #1
0
 /**
  * Initialize Twig and set defaults
  */
 public function __construct()
 {
     parent::__construct();
     require_once 'lib/Twig/Autoloader.php';
     Twig_Autoloader::register(true);
     $loader = new Twig_Loader_Filesystem($this->template_path);
     $this->engine = new Twig_Environment($loader, array());
     $this->template_extension = 'html';
     $this->ready();
 }
コード例 #2
0
 /**
  * Initialize Mustache and set defaults
  */
 public function __construct()
 {
     parent::__construct();
     $this->template_extension = 'mustache';
     require_once 'lib/Mustache/Autoloader.php';
     Mustache_Autoloader::register();
     // Init template engine.
     $options = array('loader' => new Mustache_Loader_FilesystemLoader($this->template_path));
     if (is_dir($this->template_path . 'partials/')) {
         $options['partials_loader'] = new Mustache_Loader_FilesystemLoader($this->template_path . 'partials/');
     }
     $this->engine = new Mustache_Engine($options);
 }
コード例 #3
0
 /**
  * StencilDwoo2 constructor.
  */
 public function __construct()
 {
     parent::__construct();
     /**
      * PHP version check!
      *
      * This implementation uses namespaces, which are not available before PHP 5.3.0
      */
     if (version_compare(PHP_VERSION, '5.3.0', '<')) {
         Stencil_Feedback::notification('error', 'Dwoo requires PHP 5.3 or higher. This server is running ' . PHP_VERSION);
         return;
     }
     require_once 'lib/Dwoo/Autoloader.php';
     // Register Dwoo namespace and register autoloader.
     $autoloader = new Dwoo\Autoloader();
     $autoloader->add('Dwoo', dirname(__FILE__) . '/lib/Dwoo');
     $autoloader->register(true);
     $this->engine = new Dwoo\Core($this->compile_path, $this->cache_path);
     $this->engine->setTemplateDir($this->template_path);
     // Add custom plugins to smarty (per template).
     $plugin_dir = apply_filters('Dwoo:2-template-plugin-dir', 'dwoo-plugins');
     /**
      * Add theme plugins & child-theme plugins
      */
     if (!empty($plugin_dir)) {
         $template_root = get_template_directory();
         $plugin_bases = array($template_root);
         $child_root = get_stylesheet_directory();
         if ($child_root !== $template_root) {
             $plugin_bases[] = $child_root;
         }
         foreach ($plugin_bases as $plugin_base) {
             $plugin_dir = implode(DIRECTORY_SEPARATOR, array($plugin_base, $plugin_dir, ''));
             if (is_dir($plugin_dir)) {
                 $this->engine->getLoader()->addDirectory($plugin_dir);
             }
         }
     }
     /*
      * require_once( 'plugins/function.wp.php' );
      * $this->engine->addPlugin('wp', 'dwoo_wp');
      */
     $this->ready();
 }