-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjade-php-custom.php
37 lines (34 loc) · 1.02 KB
/
jade-php-custom.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
<?php
namespace Jade;
$srcPath = dirname(__FILE__) . '/jade-php/src/';
spl_autoload_register(function($class) use($srcPath) {
if (! strstr($class, 'Jade')) return;
$c = str_replace("\\", DIRECTORY_SEPARATOR, $class);
include $srcPath . $c . '.php';
});
class UnescapedCompiler extends Compiler {
const ESCAPED = 'echo %s';
}
class CustomJade extends Jade {
/**
* Merge local options with constructor $options.
*
* @param array $options
*/
public function __construct(array $options = array())
{
parent::__construct();
$this->options = array_merge($this->options, $options);
}
/**
* @param $input
*
* @return string
*/
public function compile($input)
{
$parser = new Parser($input, null, $this->options['extension']);
$compiler = $this->options['unescaped'] ? new UnescapedCompiler($this->options, $this->filters) : new Compiler($this->options, $this->filters);
return $compiler->compile($parser->parse($input));
}
}