-
Notifications
You must be signed in to change notification settings - Fork 0
/
stencil-engine.php
61 lines (49 loc) · 1.15 KB
/
stencil-engine.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Engine code
*
* @package Stencil
* @subpackage Twig
*/
if ( ! function_exists( 'add_filter' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( class_exists( 'Stencil_Container_Implementation' ) ) :
add_action( 'init', create_function( '', 'new Stencil_Twig();' ) );
/**
* Class StencilTwig
*
* Implementation of the "Twig" templating engine
*/
class Stencil_Twig extends Stencil_Container_Implementation {
/**
* 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(
// 'cache' => $this->cache_path,
)
);
$this->template_extension = 'html';
$this->ready();
}
/**
* Fetches the Smarty compiled template
*
* @param string $template Template file to get.
*
* @return string
*/
function fetch( $template ) {
return $this->engine->render( $template, $this->variables );
}
}
endif;