diff --git a/Compiler.php b/Compiler.php index 482723f..6428c6a 100644 --- a/Compiler.php +++ b/Compiler.php @@ -21,7 +21,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Compiler.html * @since File available since Release 1.0 */ @@ -32,16 +32,16 @@ use Tale\Jade\Parser\Node; /** - * Compiles an AST got from the parser to valid PHTML, HTML or XML. + * Compiles an AST got from the parser to valid P/X/HTML or P/XML * * You can control the output-style via the options * passed to the constructor. * - * Different output types are possible (Currently, XML and HTML) + * Different output types are possible (Currently, XML ,HTML and XHTML) * * The main entry point is the `compile` method * - * The generated PHTML should be evaluated, the best method + * The generated PHTML/PXML should be evaluated, the best method * is a simple include of a generated file * * Usage example: @@ -91,12 +91,13 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Compiler.html * @since File available since Release 1.0 */ class Compiler { + use Util\ConfigurableTrait; /** * The Mode for HTML. @@ -125,13 +126,6 @@ class Compiler */ const MODE_XHTML = 2; - /** - * An array of options. - * - * @var array - */ - private $_options; - /** * The lexer that is given to the parser. * @@ -263,7 +257,7 @@ class Compiler public function __construct(array $options = null, Parser $parser = null, Lexer $lexer = null) { - $this->_options = array_replace_recursive([ + $this->defineOptions([ 'pretty' => false, 'indentStyle' => Lexer::INDENT_SPACE, 'indentWidth' => 2, @@ -336,7 +330,7 @@ public function __construct(array $options = null, Parser $parser = null, Lexer 'extensions' => ['.jd', '.jade'], 'parserOptions' => [], 'lexerOptions' => [] - ], $options ? $options : []); + ], $options); $this->_lexer = $lexer ? $lexer : new Lexer($this->_options['lexerOptions']); $this->_parser = $parser ? $parser : new Parser($this->_options['parserOptions'], $this->_lexer); @@ -531,7 +525,10 @@ public function compileFile($path) if (!$fullPath) throw new \Exception( - "File $path wasnt found in ".implode(', ', $this->_options['paths']).", Include path: ".get_include_path() + "File $path wasnt found in ". + implode(', ', $this->_options['paths']). + ", Extensions: ".implode(', ', $this->_options['extensions']). + ", Include path: ".get_include_path() ); return $this->compile(file_get_contents($fullPath), $fullPath); @@ -1003,7 +1000,7 @@ protected function handleImport(Node $node) $ext = array_search($node->filter, $this->_options['filterMap']); } - if (!empty($ext) && (!in_array($ext, $this->_options['extensions']) || $node->filter)) { + if (!empty($ext) && (!in_array(".$ext", $this->_options['extensions']) || $node->filter)) { if (!$node->filter && isset($this->_options['filterMap'][$ext])) $node->filter = $this->_options['filterMap'][$ext]; @@ -1213,11 +1210,6 @@ protected function handleMixins(Node $node) protected function handleMixin(Node $node) { - //Find the absolute document root - $root = $node; - while ($root->parent) - $root = $root->parent; - //Detach $node->parent->remove($node); diff --git a/Compiler/Exception.php b/Compiler/Exception.php index e3d00da..2e8b11d 100644 --- a/Compiler/Exception.php +++ b/Compiler/Exception.php @@ -16,7 +16,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Compiler.Exception.html * @since File available since Release 1.0 */ @@ -35,7 +35,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Compiler.Exception.html * @since File available since Release 1.0 */ diff --git a/Filter.php b/Filter.php index 89c7232..ef3d19b 100644 --- a/Filter.php +++ b/Filter.php @@ -20,7 +20,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Filter.html * @since File available since Release 1.0 */ @@ -53,7 +53,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Filter.html * @since File available since Release 1.0 */ diff --git a/Lexer.php b/Lexer.php index be8b5e3..84b6b75 100644 --- a/Lexer.php +++ b/Lexer.php @@ -18,7 +18,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Lexer.html * @since File available since Release 1.0 */ @@ -60,12 +60,13 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Lexer.html * @since File available since Release 1.0 */ class Lexer { + use Util\ConfigurableTrait; /** * Tab Indentation (\t) @@ -182,7 +183,7 @@ class Lexer public function __construct(array $options = null) { - $this->_options = array_replace([ + $this->defineOptions([ 'indentStyle' => null, 'indentWidth' => null, 'encoding' => mb_internal_encoding(), @@ -203,7 +204,7 @@ public function __construct(array $options = null) 'textLine', 'text' ] - ], $options ? $options : []); + ], $options); //Validate options if (!in_array($this->_options['indentStyle'], [null, self::INDENT_TAB, self::INDENT_SPACE])) diff --git a/Lexer/Exception.php b/Lexer/Exception.php index 2602d17..57be255 100644 --- a/Lexer/Exception.php +++ b/Lexer/Exception.php @@ -16,7 +16,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Lexer.Exception.html * @since File available since Release 1.0 */ @@ -34,7 +34,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Lexer.Exception.html * @since File available since Release 1.0 */ diff --git a/Parser.php b/Parser.php index 1eaa336..dafcebc 100644 --- a/Parser.php +++ b/Parser.php @@ -18,7 +18,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Parser.html * @since File available since Release 1.0 */ @@ -57,19 +57,13 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Parser.html * @since File available since Release 1.0 */ class Parser { - - /** - * The options array used for this parser instance. - * - * @var array - */ - private $_options; + use Util\ConfigurableTrait; /** * The lexer used in this parser instance. @@ -178,9 +172,8 @@ class Parser public function __construct(array $options = null, Lexer $lexer = null) { - $this->_options = array_replace([ - 'lexerOptions' => [] - ], $options ? $options : []); + $this->defineOptions(['lexerOptions' => $options], $options); + $this->_lexer = $lexer ? $lexer : new Lexer($this->_options['lexerOptions']); } diff --git a/Parser/Exception.php b/Parser/Exception.php index 41c5bac..eb13c2a 100644 --- a/Parser/Exception.php +++ b/Parser/Exception.php @@ -16,7 +16,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Parser.Exception.html * @since File available since Release 1.0 */ @@ -34,7 +34,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Parser.Exception.html * @since File available since Release 1.0 */ diff --git a/Parser/Node.php b/Parser/Node.php index 171e473..9b7c55e 100644 --- a/Parser/Node.php +++ b/Parser/Node.php @@ -20,7 +20,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Parser.Node.html * @since File available since Release 1.0 */ @@ -40,7 +40,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Parser.Node.html * @since File available since Release 1.0 */ @@ -462,7 +462,7 @@ public function dump($level = 0) foreach ($this->children as $child) $str .= $child->dump($level + 1); - return $str; + return trim($str); } /** diff --git a/Renderer.php b/Renderer.php index a42b166..56f64b7 100644 --- a/Renderer.php +++ b/Renderer.php @@ -18,7 +18,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Renderer.html * @since File available since Release 1.0 */ @@ -51,19 +51,13 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.html * @since File available since Release 1.0 */ class Renderer { - - /** - * The options-array for the renderer instance. - * - * @var array - */ - private $_options; + use Util\ConfigurableTrait; /** * The compiler that is used in this renderer instance. @@ -125,46 +119,35 @@ public function __construct( ) { - $this->_options = array_replace_recursive([ + $this->defineOptions([ 'adapter' => 'file', 'adapterOptions' => [], 'compilerOptions' => [], 'parserOptions' => [], 'lexerOptions' => [], - - //Abstracted settings - 'pretty' => false, - 'paths' => [], - 'standAlone' => false - ], $options ? $options : []); + ], $options); //Quick Options. //These get passed to the actual option arrays of the related objects - if (!isset($this->_options['compilerOptions']['paths'])) - $this->_options['compilerOptions']['paths'] = $this->_options['paths']; - - if (!isset($this->_options['compilerOptions']['pretty'])) - $this->_options['compilerOptions']['pretty'] = $this->_options['pretty']; - - if (!isset($this->_options['compilerOptions']['standAlone'])) - $this->_options['compilerOptions']['standAlone'] = $this->_options['standAlone']; + $this->forwardOption('lifeTime', 'adapterOptions'); + $this->forwardOption('cachePath', 'adapterOptions', 'path'); + + $this->forwardOption('paths', 'compilerOptions'); + $this->forwardOption('pretty', 'compilerOptions'); + $this->forwardOption('indentStyle', 'compilerOptions'); + $this->forwardOption('indentWidth', 'compilerOptions'); + $this->forwardOption('standAlone', 'compilerOptions'); + $this->forwardOption('extensions', 'compilerOptions'); + $this->forwardOption('mode', 'compilerOptions'); + $this->forwardOption('doctypes', 'compilerOptions'); + $this->forwardOption('filters', 'compilerOptions'); + $this->forwardOption('filterMap', 'compilerOptions'); $this->_lexer = $lexer ? $lexer : new Lexer($this->_options['lexerOptions']); $this->_parser = $parser ? $parser : new Parser($this->_options['parserOptions'], $lexer); $this->_compiler = $compiler ? $compiler : new Compiler($this->_options['compilerOptions'], $parser); } - /** - * Returns the current option-array used in this renderer instance. - * - * @return array - */ - public function getOptions() - { - - return $this->_options; - } - /** * Return the compiler instance used in this renderer instance. * diff --git a/Renderer/Adapter/File.php b/Renderer/Adapter/File.php index 4064481..03aab83 100644 --- a/Renderer/Adapter/File.php +++ b/Renderer/Adapter/File.php @@ -20,13 +20,14 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Renderer.Adapter.File.html * @since File available since Release 1.0 */ namespace Tale\Jade\Renderer\Adapter; +use RuntimeException; use Tale\Jade\Renderer; use Tale\Jade\Renderer\AdapterBase; @@ -58,7 +59,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.Adapter.File.html * @since File available since Release 1.0 */ @@ -83,11 +84,13 @@ class File extends AdapterBase public function __construct(Renderer $renderer, array $options = null) { - parent::__construct($renderer, array_replace_recursive([ + parent::__construct($renderer, $options); + + $this->setDefaults([ 'path' => './cache/views', 'extension' => '.phtml', 'lifeTime' => 0 - ], $options ? $options : [])); + ]); $dir = $this->getOption('path'); @@ -97,12 +100,12 @@ public function __construct(Renderer $renderer, array $options = null) @mkdir($dir, 0775, true); if (!is_dir($dir)) - throw new \Exception("Failed to create output directory $dir"); + throw new RuntimeException("Failed to create output directory $dir"); } //Make sure we can write to it if (!is_writable($dir)) - throw new \Exception("Output directory not writable $dir"); + throw new RuntimeException("Output directory $dir not writable"); } /** @@ -162,7 +165,7 @@ public function render($path, array $args = null) @mkdir($dir, 0775, true); if (!is_dir($dir)) - throw new \Exception( + throw new RuntimeException( "Failed to create directory $dir" ); } diff --git a/Renderer/Adapter/Stream.php b/Renderer/Adapter/Stream.php index 107258c..012b553 100644 --- a/Renderer/Adapter/Stream.php +++ b/Renderer/Adapter/Stream.php @@ -20,7 +20,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Renderer.Adapter.Stream.html * @since File available since Release 1.0 */ @@ -70,7 +70,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.Adapter.Stream.html * @since File available since Release 1.0 */ @@ -93,9 +93,9 @@ class Stream extends AdapterBase public function __construct(Renderer $renderer, array $options = null) { - parent::__construct($renderer, array_replace_recursive([ - 'scheme' => 'jade-phtml' - ], $options ? $options : [])); + parent::__construct($renderer, $options); + + $this->setDefaults(['scheme' => 'jade-phtml']); if (!Wrapper::isRegistered($this->getOption('scheme'))) Wrapper::register($this->getOption('scheme')); diff --git a/Renderer/Adapter/Stream/Wrapper.php b/Renderer/Adapter/Stream/Wrapper.php index 9949b4e..20c67bb 100644 --- a/Renderer/Adapter/Stream/Wrapper.php +++ b/Renderer/Adapter/Stream/Wrapper.php @@ -18,13 +18,15 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Renderer.Adapter.Stream.Wrapper.html * @since File available since Release 1.0 */ namespace Tale\Jade\Renderer\Adapter\Stream; +use Symfony\Component\Yaml\Exception\RuntimeException; + /** * Provides a Stream Wrapper that reads a special Data-URI. * @@ -40,7 +42,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.Adapter.Stream.Wrapper.html * @since File available since Release 1.0 */ @@ -195,6 +197,11 @@ public static function isRegistered($name) public static function register($name) { + if (self::isRegistered($name)) + throw new RuntimeException( + "The stream wrapper is already registered as $name" + ); + stream_wrapper_register($name, self::class); } @@ -208,6 +215,11 @@ public static function register($name) public static function unregister($name) { + if (!self::isRegistered($name)) + throw new RuntimeException( + "The stream wrapper is already registered not $name" + ); + stream_wrapper_unregister($name); } } \ No newline at end of file diff --git a/Renderer/AdapterBase.php b/Renderer/AdapterBase.php index aa2713c..2f9f0f2 100644 --- a/Renderer/AdapterBase.php +++ b/Renderer/AdapterBase.php @@ -18,7 +18,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/Renderer.AdapterBase.html * @since File available since Release 1.0 */ @@ -26,6 +26,7 @@ namespace Tale\Jade\Renderer; use Tale\Jade\Renderer; +use Tale\Jade\Util\ConfigurableTrait; /** * Acts as a base class for renderer adapters. @@ -40,12 +41,13 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.AdapterBase.html * @since File available since Release 1.0 */ abstract class AdapterBase { + use ConfigurableTrait; /** * The renderer this adapter got created in. @@ -54,12 +56,6 @@ abstract class AdapterBase */ private $_renderer; - /** - * The options array for this adapter. - * - * @var array - */ - private $_options; /** * Creates a new adapter. @@ -81,7 +77,9 @@ public function __construct(Renderer $renderer, array $options = null) { $this->_renderer = $renderer; - $this->_options = $options ? $options : []; + + if ($options) + $this->setOptions($options); } /** @@ -95,21 +93,6 @@ public function getRenderer() return $this->_renderer; } - /** - * Returns an option by a given name. - * - * The existence of the option is not checked - * - * @param string $name the name of the option - * - * @return mixed the value of the option - */ - protected function getOption($name) - { - - return $this->_options[$name]; - } - /** * Renders a jade file by a given path. * diff --git a/Test/ConfigTest.php b/Test/ConfigTest.php new file mode 100644 index 0000000..8662273 --- /dev/null +++ b/Test/ConfigTest.php @@ -0,0 +1,46 @@ + $value]); + + $this->assertEquals($value, $compiler->getOption($option)); + } + + /** + * @dataProvider compilerOptionProvider + */ + public function testRendererForwardsOptionsToCompiler($option, $value) + { + + $renderer = new Renderer([$option => $value]); + + $this->assertEquals($value, $renderer->getCompiler()->getOption($option)); + } + + public function compilerOptionProvider() + { + + return [ + ['paths', ['/a', '/b', '/c']], + ['pretty', true], + ['indentStyle', '-'], + ['indentWidth', 8], + ['standAlone', true], + ['extensions', ['.a', '.b', '.c']], + ['mode', Compiler::MODE_XHTML] + ]; + } +} \ No newline at end of file diff --git a/Test/IssueTest.php b/Test/IssueTest.php index 77067ac..eb42b4c 100644 --- a/Test/IssueTest.php +++ b/Test/IssueTest.php @@ -24,6 +24,12 @@ public function setUp() ]); } + public function testIssue19() + { + + $this->assertEquals('

Columnus



Coluumns



Columns

array(0=>array(\'class\'=>\'yii\\\\grid\\\\SerialColumn\',),1=>\'id\',2=>\'username\',3=>\'auth_key\',4=>\'password_hash\',5=>array(\'class\'=>\'yii\\\\grid\\\\ActionColumn\',),)array(0=>array(\'class\'=>\'yii\\\\grid\\\\SerialColumn\',),1=>\'id\',2=>\'username\',3=>\'auth_key\',4=>\'password_hash\',5=>\'password_reset_token\',6=>array(\'class\'=>\'yii\\\\grid\\\\ActionColumn\',),)', $this->_renderer->render('issue-19')); + } + public function testIssue33() { @@ -40,4 +46,15 @@ public function testIssue42() )); } + public function testIssue48() + { + + $this->assertEquals('

Hello

', $this->_renderer->render( + 'issue-48/1' + )); + + $this->assertEquals(' ', $this->_renderer->render( + 'issue-48/views/view.ctp' + )); + } } \ No newline at end of file diff --git a/Test/VariableTest.php b/Test/VariableTest.php index eccfa58..195a444 100644 --- a/Test/VariableTest.php +++ b/Test/VariableTest.php @@ -30,10 +30,4 @@ public function testAssignment() 'existing' => ['style' => ['width' => '100%'], 'class' => 'test'] ])); } - - public function testIssue19() - { - - $this->assertEquals('

Columnus



Coluumns



Columns

array(0=>array(\'class\'=>\'yii\\\\grid\\\\SerialColumn\',),1=>\'id\',2=>\'username\',3=>\'auth_key\',4=>\'password_hash\',5=>array(\'class\'=>\'yii\\\\grid\\\\ActionColumn\',),)array(0=>array(\'class\'=>\'yii\\\\grid\\\\SerialColumn\',),1=>\'id\',2=>\'username\',3=>\'auth_key\',4=>\'password_hash\',5=>\'password_reset_token\',6=>array(\'class\'=>\'yii\\\\grid\\\\ActionColumn\',),)', $this->_renderer->render('issue-19')); - } } \ No newline at end of file diff --git a/Test/views/variables/issue-19.jade b/Test/views/issues/issue-19.jade similarity index 100% rename from Test/views/variables/issue-19.jade rename to Test/views/issues/issue-19.jade diff --git a/Test/views/issues/issue-48/1.jade b/Test/views/issues/issue-48/1.jade new file mode 100644 index 0000000..957a95e --- /dev/null +++ b/Test/views/issues/issue-48/1.jade @@ -0,0 +1 @@ +include mixin \ No newline at end of file diff --git a/Test/views/issues/issue-48/Mixins/button_with_preloader.ctp.jade b/Test/views/issues/issue-48/Mixins/button_with_preloader.ctp.jade new file mode 100644 index 0000000..dbd4a60 --- /dev/null +++ b/Test/views/issues/issue-48/Mixins/button_with_preloader.ctp.jade @@ -0,0 +1,3 @@ + +mixin button_with_preloader(title) + button= $title \ No newline at end of file diff --git a/Test/views/issues/issue-48/mixin.jade b/Test/views/issues/issue-48/mixin.jade new file mode 100644 index 0000000..733281d --- /dev/null +++ b/Test/views/issues/issue-48/mixin.jade @@ -0,0 +1 @@ +h2 Hello \ No newline at end of file diff --git a/Test/views/issues/issue-48/views/view.ctp.jade b/Test/views/issues/issue-48/views/view.ctp.jade new file mode 100644 index 0000000..7f3272c --- /dev/null +++ b/Test/views/issues/issue-48/views/view.ctp.jade @@ -0,0 +1,6 @@ + +include ../Mixins/button_with_preloader.ctp.jade + + + ++button_with_preloader(___('Submit'))#btn_submit_feedback.right._no-margin-bottom \ No newline at end of file diff --git a/Util/ConfigurableTrait.php b/Util/ConfigurableTrait.php new file mode 100644 index 0000000..02218e8 --- /dev/null +++ b/Util/ConfigurableTrait.php @@ -0,0 +1,68 @@ +setOptions($defaults); + + if ($userOptions) + $this->setOptions($userOptions, true); + } + + public function getOptions() + { + + return $this->_options; + } + + public function getOption($name, $default = null) + { + + return isset($this->_options[$name]) ? $this->_options[$name] : $default; + } + + public function setOptions(array $options, $recursive = false, $reverse = false) + { + + $merge = 'array_replace'; + + if ($recursive) + $merge .= '_recursive'; + + $this->_options = $reverse + ? $merge($options, $this->_options) + : $merge($this->_options, $options); + + return $this; + } + + public function setDefaults(array $defaults, $recursive = false) + { + + return $this->setOptions($defaults, $recursive, true); + } + + public function setOption($name, $value) + { + + $this->_options[$name] = $value; + + return $this; + } + + public function forwardOption($name, $target, $targetName = null) + { + + $targetName = $targetName ? $targetName : $name; + + if (isset($this->_options[$name])) + $this->_options[$target][$targetName] = $this->_options[$name]; + } +} \ No newline at end of file diff --git a/functions.php b/functions.php index 861f31e..09fbbf1 100644 --- a/functions.php +++ b/functions.php @@ -18,7 +18,7 @@ * @author Talesoft * @copyright Copyright (c) 2015 Talesoft (http://talesoft.io) * @license http://licenses.talesoft.io/2015/MIT.txt MIT License - * @version 1.3.4 + * @version 1.3.5 * @link http://jade.talesoft.io/docs/files/functions.html * @since File available since Tag 1.0.1 */ diff --git a/tasks.php b/tasks.php index 1130982..394a6e2 100644 --- a/tasks.php +++ b/tasks.php @@ -10,7 +10,7 @@ './.git' ]; -$newVersion = '1.3.4'; +$newVersion = '1.3.5'; if (!$newVersion) {