diff --git a/.gitignore b/.gitignore
index 2245dfc..2c131e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,5 @@
.DS_Store
Thumbs.db
-composer.lock
phpdoc.xml
*.phtml
diff --git a/Compiler.php b/Compiler.php
index 7b8be11..9773b15 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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/files/Compiler.html
* @since File available since Release 1.0
*/
@@ -92,7 +92,7 @@
* @author Talesoft
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
- * @version 1.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Compiler.html
* @since File available since Release 1.0
*/
@@ -132,14 +132,14 @@ class Compiler
*
* @var Lexer
*/
- private $_lexer;
+ private $lexer;
/**
* The parse this compiler instance gets its nodes off.
*
* @var Parser
*/
- private $_parser;
+ private $parser;
/**
* The current file stack.
@@ -149,7 +149,7 @@ class Compiler
*
* @var string[]
*/
- private $_files;
+ private $files;
/**
* The mixins we found in the whole input.
@@ -171,14 +171,14 @@ class Compiler
*
* @var array
*/
- private $_mixins;
+ private $mixins;
/**
* A stack of names of the mixins we actually called in the code.
*
* @var string[]
*/
- private $_calledMixins;
+ private $calledMixins;
/**
* A list of all blocks in our whole input.
@@ -187,7 +187,7 @@ class Compiler
*
* @var Node[]
*/
- private $_blocks;
+ private $blocks;
/**
* The level we're currently in.
@@ -198,14 +198,14 @@ class Compiler
*
* @var int
*/
- private $_level;
+ private $level;
/**
* Contains the current iterator ID to avoid name collisions.
*
* @var int
*/
- private $_iteratorId;
+ private $iteratorId;
/**
* Creates a new compiler instance.
@@ -340,8 +340,8 @@ public function __construct(array $options = null, Parser $parser = null, Lexer
'lexerOptions' => []
], $options);
- $this->_lexer = $lexer ? $lexer : new Lexer($this->_options['lexerOptions']);
- $this->_parser = $parser ? $parser : new Parser($this->_options['parserOptions'], $this->_lexer);
+ $this->lexer = $lexer ? $lexer : new Lexer($this->options['lexerOptions']);
+ $this->parser = $parser ? $parser : new Parser($this->options['parserOptions'], $this->lexer);
}
/**
@@ -352,7 +352,7 @@ public function __construct(array $options = null, Parser $parser = null, Lexer
public function getLexer()
{
- return $this->_lexer;
+ return $this->lexer;
}
/**
@@ -363,7 +363,7 @@ public function getLexer()
public function getParser()
{
- return $this->_parser;
+ return $this->parser;
}
/**
@@ -378,7 +378,7 @@ public function getParser()
public function addPath($path)
{
- $this->_options['paths'][] = $path;
+ $this->options['paths'][] = $path;
return $this;
}
@@ -410,7 +410,7 @@ public function addFilter($name, $callback)
"Argument 2 of addFilter must be valid callback"
);
- $this->_options['filters'][$name] = $callback;
+ $this->options['filters'][$name] = $callback;
return $this;
}
@@ -443,18 +443,18 @@ public function compile($input, $path = null)
{
//Compiler reset
- $this->_files = $path ? [$path] : [];
- $this->_mixins = [];
- $this->_calledMixins = [];
- $this->_blocks = [];
- $this->_level = 0;
- $this->_iteratorId = 0;
+ $this->files = $path ? [$path] : [];
+ $this->mixins = [];
+ $this->calledMixins = [];
+ $this->blocks = [];
+ $this->level = 0;
+ $this->iteratorId = 0;
//Parse the input into an AST
$node = null;
try {
- $node = $this->_parser->parse($input);
+ $node = $this->parser->parse($input);
} catch(\Exception $e) {
//This is needed to be able to keep track of the
@@ -474,12 +474,12 @@ public function compile($input, $path = null)
//Reset the level again for our next operations
- $this->_level = 0;
+ $this->level = 0;
//Now we append/prepend specific stuff (like mixin functions and helpers)
$mixins = $this->compileMixins();
$helpers = '';
- if ($this->_options['standAlone']) {
+ if ($this->options['standAlone']) {
$helpers = file_get_contents(__DIR__.'/Compiler/functions.php')."\n?>\n";
$helpers .= $this->createCode('namespace {');
@@ -488,14 +488,14 @@ public function compile($input, $path = null)
//Put everything together
$phtml = implode('', [$helpers, $mixins, $phtml]);
- if ($this->_options['standAlone'])
+ if ($this->options['standAlone'])
$phtml .= $this->createCode('}');
//Reset the files after compilation so that compileFile may resolve correctly
//Happens when you call compileFile twice on different files
//Note that Compiler only uses the include-path, when there is no file in the
//file name storage $_files
- $this->_files = [];
+ $this->files = [];
//Return the compiled PHTML
return trim($phtml);
@@ -528,8 +528,8 @@ public function compileFile($path)
if (!$fullPath)
throw new \Exception(
"File $path wasnt found in ".
- implode(', ', $this->_options['paths']).
- ", Extensions: ".implode(', ', $this->_options['extensions']).
+ implode(', ', $this->options['paths']).
+ ", Extensions: ".implode(', ', $this->options['extensions']).
", Include path: ".get_include_path()
);
@@ -549,7 +549,7 @@ public function compileFile($path)
protected function isMode($mode)
{
- return $this->_options['mode'] === $mode;
+ return $this->options['mode'] === $mode;
}
/**
@@ -604,7 +604,7 @@ protected function isXhtml()
protected function isScalar($value)
{
- return preg_match('/^([a-z0-9\_\-]+|"[^"]*"|\'[^\']*\')$/i', $value) ? true : false;
+ return empty($value) || preg_match('/^([a-z0-9\_\-]+|"[^"]*"|\'[^\']*\')$/i', $value) ? true : false;
}
@@ -619,7 +619,7 @@ protected function isScalar($value)
protected function compileScalar($value, $inCode = false)
{
- $sequences = $this->_options['escapeSequences'];
+ $sequences = $this->options['escapeSequences'];
return $this->interpolate(trim(str_replace(array_keys($sequences), $sequences, $value), '\'"'), $inCode);
}
@@ -736,7 +736,7 @@ protected function interpolate($string, $inCode = false)
: $subject;
if ($escapeType !== '!')
- $code = "htmlentities($code, \\ENT_QUOTES, '".$this->_options['escapeCharset']."')";
+ $code = "htmlentities($code, \\ENT_QUOTES, '".$this->options['escapeCharset']."')";
$replacement = !$inCode ? $this->createShortCode($code) : '\'.('.$code.').\'';
break;
@@ -744,14 +744,14 @@ protected function interpolate($string, $inCode = false)
//This is a fix for in IE conditional tags
if (strtolower($subject) === 'endif')
- break;
+ break 2;
- $node = $this->_parser->parse($subject);
+ $node = $this->parser->parse($subject);
$code = $this->compileNode($node);
if ($escapeType === '!') {
- $code = 'htmlentities('.$this->exportScalar($code).', \\ENT_QUOTES, \''.$this->_options['escapeCharset'].'\')';
+ $code = 'htmlentities('.$this->exportScalar($code).', \\ENT_QUOTES, \''.$this->options['escapeCharset'].'\')';
$code = !$inCode ? $this->createShortCode($code) : '\'.('.$code.').\'';
}
@@ -775,7 +775,7 @@ protected function interpolate($string, $inCode = false)
protected function newLine()
{
- return $this->_options['pretty']
+ return $this->options['pretty']
? "\n"
: '';
}
@@ -792,8 +792,8 @@ protected function newLine()
protected function indent($offset = 0)
{
- return $this->_options['pretty']
- ? str_repeat($this->_options['indentStyle'], ($this->_level + $offset) * $this->_options['indentWidth'])
+ return $this->options['pretty']
+ ? str_repeat($this->options['indentStyle'], ($this->level + $offset) * $this->options['indentWidth'])
: '';
}
@@ -813,10 +813,10 @@ protected function createCode($code, $prefix = '')
if (strpos($code, "\n") !== false) {
- $this->_level++;
+ $this->level++;
$code = implode($this->newLine().$this->indent(), preg_split("/\n[\t ]*/", $code))
.$this->newLine().$this->indent(-1);
- $this->_level--;
+ $this->level--;
}
return $prefix.$code.$suffix;
@@ -937,19 +937,19 @@ protected function compileDoctype(Node $node)
{
$name = $node->name;
- $value = isset($this->_options['doctypes'][$name]) ? $this->_options['doctypes'][$name] : '';
+ $value = isset($this->options['doctypes'][$name]) ? $this->options['doctypes'][$name] : '';
if ($name === 'xml') {
- $this->_options['mode'] = self::MODE_XML;
+ $this->options['mode'] = self::MODE_XML;
- if ($this->_options['echoXmlDoctype'])
+ if ($this->options['echoXmlDoctype'])
$value = "='$value'?>";
- } else if (in_array($name, $this->_options['xhtmlModes']))
- $this->_options['mode'] = self::MODE_XHTML;
+ } else if (in_array($name, $this->options['xhtmlModes']))
+ $this->options['mode'] = self::MODE_XHTML;
else
- $this->_options['mode'] = self::MODE_HTML;
+ $this->options['mode'] = self::MODE_HTML;
return $value;
}
@@ -975,8 +975,8 @@ protected function compileDoctype(Node $node)
public function resolvePath($path, $extensions = null)
{
- $paths = $this->_options['paths'];
- $exts = $extensions ? $extensions : $this->_options['extensions'];
+ $paths = $this->options['paths'];
+ $exts = $extensions ? $extensions : $this->options['extensions'];
if (is_array($exts)) {
@@ -1003,8 +1003,8 @@ public function resolvePath($path, $extensions = null)
}
//Add the path were currently compiling in (e.g. include, extends)
- if (count($this->_files) > 0)
- $paths[] = dirname(end($this->_files));
+ if (count($this->files) > 0)
+ $paths[] = dirname(end($this->files));
//Iterate paths and check file existence via realpath
foreach ($paths as $directory) {
@@ -1031,7 +1031,7 @@ protected function handleImports(Node $node)
foreach ($node->find('import') as $importNode) {
- if (!$this->_options['allowImports'])
+ if (!$this->options['allowImports'])
$this->throwException(
'Imports are not allowed in this compiler instance',
$node
@@ -1059,21 +1059,21 @@ protected function handleImport(Node $node)
$ext = pathinfo($path, \PATHINFO_EXTENSION);
- if (empty($ext) && $node->filter && in_array($node->filter, $this->_options['filterMap'], true)) {
+ if (empty($ext) && $node->filter && in_array($node->filter, $this->options['filterMap'], true)) {
//Get our extension from our filter map
- $ext = array_search($node->filter, $this->_options['filterMap']);
+ $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];
+ if (!$node->filter && isset($this->options['filterMap'][$ext]))
+ $node->filter = $this->options['filterMap'][$ext];
$fullPath = $this->resolvePath($path, ".$ext");
if (!$fullPath)
$this->throwException(
- "File $path not found in ".implode(', ', $this->_options['paths']).", Include path: ".get_include_path(),
+ "File $path not found in ".implode(', ', $this->options['paths']).", Include path: ".get_include_path(),
$node
);
@@ -1111,14 +1111,14 @@ protected function handleImport(Node $node)
if (!$fullPath)
$this->throwException(
- "File $path wasnt found in ".implode(', ', $this->_options['paths']).", Include path: ".get_include_path(),
+ "File $path wasnt found in ".implode(', ', $this->options['paths']).", Include path: ".get_include_path(),
$node
);
- $importedNode = $this->_parser->parse(file_get_contents($fullPath));
- $this->_files[] = $fullPath;
+ $importedNode = $this->parser->parse(file_get_contents($fullPath));
+ $this->files[] = $fullPath;
$this->handleImports($importedNode);
- array_pop($this->_files);
+ array_pop($this->files);
//Notice that include might have an expansion before
//We'd need to resolve that before we remove the import \Tale\Jade\Parser\Node alltogether
@@ -1146,8 +1146,8 @@ protected function handleImport(Node $node)
protected function handleBlocks(Node $node)
{
- $this->_blocks = $node->findArray('block');
- foreach ($this->_blocks as $blockNode)
+ $this->blocks = $node->findArray('block');
+ foreach ($this->blocks as $blockNode)
$this->handleBlock($blockNode);
return $this;
@@ -1171,7 +1171,7 @@ protected function handleBlock(Node $node)
return $this;
//Find all other blocks with that name
- foreach ($this->_blocks as $block) {
+ foreach ($this->blocks as $block) {
if ($block === $node || $block->name !== $node->name)
continue;
@@ -1237,20 +1237,20 @@ protected function handleMixins(Node $node)
$mixins = $node->findArray('mixin');
- //Save all mixins in $this->_mixins for our mixinCalls to reference them
+ //Save all mixins in $this->mixins for our mixinCalls to reference them
foreach ($mixins as $mixinNode) {
- if (isset($this->_mixins[$mixinNode->name]) && !$this->_options['replaceMixins'])
+ if (isset($this->mixins[$mixinNode->name]) && !$this->options['replaceMixins'])
$this->throwException(
"Duplicate mixin name $mixinNode->name",
$mixinNode
);
- $this->_mixins[$mixinNode->name] = $mixinNode;
+ $this->mixins[$mixinNode->name] = $mixinNode;
}
//Handle the mixins
- foreach ($this->_mixins as $mixinNode) {
+ foreach ($this->mixins as $mixinNode) {
$this->handleMixin($mixinNode);
}
@@ -1278,7 +1278,7 @@ protected function handleMixin(Node $node)
//Detach
$node->parent->remove($node);
- $this->_mixins[$node->name] = [
+ $this->mixins[$node->name] = [
'node' => $node,
'phtml' => $this->compileChildren($node->children, false)
];
@@ -1297,17 +1297,17 @@ protected function handleMixin(Node $node)
protected function compileMixins()
{
- if (count($this->_mixins) < 1)
+ if (count($this->mixins) < 1)
return '';
$phtml = '';
$phtml .= $this->createCode('$__args = isset($__args) ? $__args : [];').$this->newLine();
$phtml .= $this->createCode('$__mixins = [];').$this->newLine();
- foreach ($this->_mixins as $name => $mixin) {
+ foreach ($this->mixins as $name => $mixin) {
//Don't compile the mixin if we dont use it (opt-out)
- if (!$this->_options['compileUncalledMixins'] && !in_array($name, $this->_calledMixins, true))
+ if (!$this->options['compileUncalledMixins'] && !in_array($name, $this->calledMixins, true))
continue; //Skip compilation
//Put the arguments together
@@ -1363,16 +1363,16 @@ protected function compileMixinCall(Node $node)
$name = $node->name;
$hasBlock = false;
- if (!isset($this->_mixins[$name]))
+ if (!isset($this->mixins[$name]))
$this->throwException(
"Mixin $name is not defined",
$node
);
- if (!in_array($name, $this->_calledMixins, true))
- $this->_calledMixins[] = $name;
+ if (!in_array($name, $this->calledMixins, true))
+ $this->calledMixins[] = $name;
- $mixin = $this->_mixins[$name];
+ $mixin = $this->mixins[$name];
$phtml = '';
if (count($node->children) > 0) {
@@ -1631,7 +1631,7 @@ protected function compileEach(Node $node)
if ($node->keyName)
$as = "\${$node->keyName} => ".$as;
- $var = '$__iterator'.($this->_iteratorId++);
+ $var = '$__iterator'.($this->iteratorId++);
$phtml = $this->createCode("$var = {$subject};").$this->newLine();
$phtml .= $this->indent().$this->createCode("foreach ($var as $as) {").$this->newLine();
$phtml .= $this->compileChildren($node->children).$this->newLine();
@@ -1795,7 +1795,7 @@ protected function compileVariable(Node $node)
//No children, this is simple variable output (Escaped!)
return $this->createShortCode(
- "htmlentities(\${$node->name}, \\ENT_QUOTES, '".$this->_options['escapeCharset']."')"
+ "htmlentities(\${$node->name}, \\ENT_QUOTES, '".$this->options['escapeCharset']."')"
);
}
@@ -1825,13 +1825,13 @@ protected function compileFilter(Node $node)
$name = $node->name;
- if (!isset($this->_options['filters'][$name]))
+ if (!isset($this->options['filters'][$name]))
$this->throwException(
"Filter $name doesnt exist",
$node
);
- $result = call_user_func($this->_options['filters'][$name], $node, $this->indent(), $this->newLine(), $this);
+ $result = call_user_func($this->options['filters'][$name], $node, $this->indent(), $this->newLine(), $this);
return $result instanceof \Tale\Jade\Parser\Node ? $this->compileNode($result) : (string)$result;
}
@@ -1851,26 +1851,26 @@ protected function compileChildren(array $nodes, $indent = true, $allowInline =
{
$phtml = '';
- $this->_level += $indent ? 1 : 0;
+ $this->level += $indent ? 1 : 0;
if (count($nodes) === 1 && $allowInline) {
$compiled = $this->compileNode($nodes[0]);
- $this->_level--;
+ $this->level--;
return trim($compiled);
}
foreach ($nodes as $idx => $node) {
- if ($node->type === 'text' && !$this->_options['pretty'] && $idx > 0) {
+ if ($node->type === 'text' && !$this->options['pretty'] && $idx > 0) {
$phtml .= ' ';
}
$phtml .= $this->newLine().$this->indent().$this->compileNode($node);
}
- $this->_level -= $indent ? 1 : 0;
+ $this->level -= $indent ? 1 : 0;
return $phtml;
}
@@ -1890,19 +1890,21 @@ protected function compileElement(Node $node)
$phtml = '';
if (!$node->tag)
- $node->tag = $this->_options['defaultTag'];
+ $node->tag = $this->options['defaultTag'];
$phtml .= "<{$node->tag}";
$htmlMode = $this->isHtml();
- $anyHtmlMode = $this->isHtml() || $this->isXhtml();
+ $xhtmlMode = $this->isXhtml();
$xmlMode = $this->isXml();
+ $anyHtmlMode = $htmlMode || $xhtmlMode;
+ $anyXmlMode = $xmlMode || $xhtmlMode;
$nodeAttributes = $node->attributes;
//In the following lines we kind of map assignments
//to attributes (that's the core of how cross-assignments work)
- //&href('a', 'b', 'c') will add 3 attributes href=a, href=b and href=b
+ //&href('a', 'b', 'c') will add 3 attributes href=a, href=b and href=b lkrueger
//to the attributes we work on
foreach ($node->assignments as $assignment) {
@@ -1975,7 +1977,7 @@ protected function compileElement(Node $node)
if ($this->isVariable($value) && !$attr->unchecked) {
- $values[] = 'isset('.$value.') ? '.$value.' : false';
+ $values[] = 'isset(' . $value . ') ? ' . $value . ' : false';
} else {
$values[] = $value;
@@ -1986,13 +1988,16 @@ protected function compileElement(Node $node)
$escaped = false;
}
- //In HTML-mode, self-repeating attributes are automatically expanded
- if ($anyHtmlMode && count($values) < 1 && in_array($name, $this->_options['selfRepeatingAttributes'])) {
+ //In XML-mode, self-repeating attributes are automatically expanded
+ if ($anyXmlMode || $xmlMode && count($values) < 1) {
- $values[] = $name;
+ if ($xhtmlMode && in_array($name, $this->options['selfRepeatingAttributes']))
+ $values[] = $name;
+ else
+ $values[] = '';
}
- $quot = $this->_options['quoteStyle'];
+ $quot = $this->options['quoteStyle'];
$builder = '\\Tale\\Jade\\Compiler\\build_value';
//Handle specific attribute styles for HTML
@@ -2014,10 +2019,13 @@ protected function compileElement(Node $node)
$escaped = $escaped ? 'true' : 'false';
$pair = '';
- if (count(array_filter($values, [$this, 'isScalar'])) === count($values)) {
+ if (count($values) < 1) {
+
+ $pair = " $name";
+ } else if (count(array_filter($values, [$this, 'isScalar'])) === count($values)) {
//We got all scalar values, we can evaluate them directly, so no code needed in the PHTML output
- $pair .= " $name=";
+ $pair = " $name=";
$values = array_map(function ($val) {
return $this->compileScalar($val);
@@ -2062,7 +2070,7 @@ protected function compileElement(Node $node)
}
$hasChildren = count($node->children) > 0;
- $isSelfClosing = in_array($node->tag, $this->_options['selfClosingTags']);
+ $isSelfClosing = in_array($node->tag, $this->options['selfClosingTags']);
if (!$hasChildren && (!$htmlMode || !$isSelfClosing)) {
@@ -2106,7 +2114,7 @@ protected function compileText(Node $node)
if ($node->escaped)
$text = $this->createShortCode(
- 'htmlentities('.$this->exportScalar($node->value, '\'', true).', \\ENT_QUOTES, \''.$this->_options['escapeCharset'].'\')'
+ 'htmlentities('.$this->exportScalar($node->value, '\'', true).', \\ENT_QUOTES, \''.$this->options['escapeCharset'].'\')'
);
else
$text = $this->interpolate($node->value);
@@ -2124,7 +2132,7 @@ protected function compileText(Node $node)
protected function compileExpression(Node $node)
{
- $code = $node->escaped ? 'htmlentities(%s, \\ENT_QUOTES, \''.$this->_options['escapeCharset'].'\')' : '%s';
+ $code = $node->escaped ? 'htmlentities(%s, \\ENT_QUOTES, \''.$this->options['escapeCharset'].'\')' : '%s';
$value = rtrim(trim($node->value), ';');
@@ -2258,8 +2266,8 @@ protected function throwException($message, Node $relatedNode = null)
.' at '.$relatedNode->line
.':'.$relatedNode->offset.')';
- if (!empty($this->_files))
- $message .= "\n[".end($this->_files).']';
+ if (!empty($this->files))
+ $message .= "\n[".end($this->files).']';
throw new Exception(
"Failed to compile Jade: $message"
diff --git a/Compiler/Exception.php b/Compiler/Exception.php
index 5464ee9..6063686 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.4.0
+ * @version 1.4.2
* @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.4.0
+ * @version 1.4.2
* @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 80e8a2e..e847449 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.4.0
+ * @version 1.4.2
* @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.4.0
+ * @version 1.4.2
* @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 b3d58b2..f208552 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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/files/Lexer.html
* @since File available since Release 1.0
*/
@@ -62,7 +62,7 @@
* @author Talesoft
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
- * @version 1.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Lexer.html
* @since File available since Release 1.0
*/
@@ -85,28 +85,28 @@ class Lexer
*
* @var string
*/
- private $_input;
+ private $input;
/**
* The total length of the current input.
*
* @var int
*/
- private $_length;
+ private $length;
/**
* The current position inside the input string.
*
* @var int
*/
- private $_position;
+ private $position;
/**
* The current line we are on.
*
* @var int
*/
- private $_line;
+ private $line;
/**
* The current offset in a line we are on.
@@ -115,21 +115,21 @@ class Lexer
*
* @var int
*/
- private $_offset;
+ private $offset;
/**
* The current indentation level we are on.
*
* @var int
*/
- private $_level;
+ private $level;
/**
* The current indentation character.
*
* @var string
*/
- private $_indentStyle;
+ private $indentStyle;
/**
* The width of the indentation.
@@ -139,7 +139,7 @@ class Lexer
*
* @var string
*/
- private $_indentWidth;
+ private $indentWidth;
/**
* The last result gotten via ->peek().
@@ -147,7 +147,7 @@ class Lexer
* @see Lexer->peek
* @var string
*/
- private $_lastPeekResult;
+ private $lastPeekResult;
/**
* The last matches gotten via ->match()
@@ -155,7 +155,7 @@ class Lexer
* @see Lexer->match
* @var array
*/
- private $_lastMatches;
+ private $lastMatches;
/**
* Creates a new lexer instance.
@@ -209,13 +209,13 @@ public function __construct(array $options = null)
], $options);
//Validate options
- if (!in_array($this->_options['indentStyle'], [null, self::INDENT_TAB, self::INDENT_SPACE]))
+ if (!in_array($this->options['indentStyle'], [null, self::INDENT_TAB, self::INDENT_SPACE]))
throw new RuntimeException(
"indentStyle needs to be null or one of the INDENT_* constants of the lexer"
);
- if (!is_null($this->_options['indentWidth']) &&
- (!is_int($this->_options['indentWidth']) || $this->_options['indentWidth'] < 1)
+ if (!is_null($this->options['indentWidth']) &&
+ (!is_int($this->options['indentWidth']) || $this->options['indentWidth'] < 1)
)
throw new RuntimeException(
"indentWidth needs to be a integer above 0"
@@ -230,7 +230,7 @@ public function __construct(array $options = null)
public function getInput()
{
- return $this->_input;
+ return $this->input;
}
/**
@@ -241,7 +241,7 @@ public function getInput()
public function getLength()
{
- return $this->_length;
+ return $this->length;
}
/**
@@ -252,7 +252,7 @@ public function getLength()
public function getPosition()
{
- return $this->_position;
+ return $this->position;
}
/**
@@ -263,7 +263,7 @@ public function getPosition()
public function getLine()
{
- return $this->_line;
+ return $this->line;
}
/**
@@ -274,7 +274,7 @@ public function getLine()
public function getOffset()
{
- return $this->_offset;
+ return $this->offset;
}
/**
@@ -285,7 +285,7 @@ public function getOffset()
public function getLevel()
{
- return $this->_level;
+ return $this->level;
}
/**
@@ -296,7 +296,7 @@ public function getLevel()
public function getIndentStyle()
{
- return $this->_indentStyle;
+ return $this->indentStyle;
}
/**
@@ -307,7 +307,7 @@ public function getIndentStyle()
public function getIndentWidth()
{
- return $this->_indentWidth;
+ return $this->indentWidth;
}
/**
@@ -319,7 +319,7 @@ public function getIndentWidth()
public function getLastPeekResult()
{
- return $this->_lastPeekResult;
+ return $this->lastPeekResult;
}
/**
@@ -331,7 +331,7 @@ public function getLastPeekResult()
public function getLastMatches()
{
- return $this->_lastMatches;
+ return $this->lastMatches;
}
/**
@@ -358,23 +358,23 @@ public function getLastMatches()
public function lex($input)
{
- $this->_input = rtrim(str_replace([
+ $this->input = rtrim(str_replace([
"\r", "\0"
], '', $input))."\n";
- $this->_length = $this->strlen($this->_input);
- $this->_position = 0;
+ $this->length = $this->strlen($this->input);
+ $this->position = 0;
- $this->_line = 1;
- $this->_offset = 0;
- $this->_level = 0;
+ $this->line = 1;
+ $this->offset = 0;
+ $this->level = 0;
- $this->_indentStyle = $this->_options['indentStyle'];
- $this->_indentWidth = $this->_options['indentWidth'];
+ $this->indentStyle = $this->options['indentStyle'];
+ $this->indentWidth = $this->options['indentWidth'];
- $this->_lastPeekResult = null;
- $this->_lastMatches = null;
+ $this->lastPeekResult = null;
+ $this->lastMatches = null;
- foreach ($this->scanFor($this->_options['scans'], true) as $token)
+ foreach ($this->scanFor($this->options['scans'], true) as $token)
yield $token;
}
@@ -419,7 +419,7 @@ public function dump($input)
protected function isAtEnd()
{
- return $this->_position >= $this->_length;
+ return $this->position >= $this->length;
}
/**
@@ -438,9 +438,9 @@ protected function isAtEnd()
protected function peek($length = 1)
{
- $this->_lastPeekResult = $this->substr($this->_input, 0, $length);
+ $this->lastPeekResult = $this->substr($this->input, 0, $length);
- return $this->_lastPeekResult;
+ return $this->lastPeekResult;
}
/**
@@ -463,18 +463,18 @@ protected function consume($length = null)
if ($length === null) {
- if ($this->_lastPeekResult === null)
+ if ($this->lastPeekResult === null)
$this->throwException(
"Failed to consume: Nothing has been peeked and you"
." didnt pass a length to consume"
);
- $length = $this->strlen($this->_lastPeekResult);
+ $length = $this->strlen($this->lastPeekResult);
}
- $this->_input = $this->substr($this->_input, $length);
- $this->_position += $length;
- $this->_offset += $length;
+ $this->input = $this->substr($this->input, $length);
+ $this->position += $length;
+ $this->offset += $length;
return $this;
}
@@ -511,22 +511,22 @@ protected function read($callback, $length = 1)
while (!$this->isAtEnd() && $callback($this->peek($length))) {
//Keep $_line and $_offset updated
- $newLines = $this->substr_count($this->_lastPeekResult, "\n");
- $this->_line += $newLines;
+ $newLines = $this->substr_count($this->lastPeekResult, "\n");
+ $this->line += $newLines;
if ($newLines) {
- if (strlen($this->_lastPeekResult) === 1)
- $this->_offset = 0;
+ if (strlen($this->lastPeekResult) === 1)
+ $this->offset = 0;
else {
- $parts = explode("\n", $this->_lastPeekResult);
- $this->_offset = strlen($parts[count($parts) - 1]) - 1;
+ $parts = explode("\n", $this->lastPeekResult);
+ $this->offset = strlen($parts[count($parts) - 1]) - 1;
}
}
$this->consume();
- $result .= $this->_lastPeekResult;
+ $result .= $this->lastPeekResult;
}
return $result;
@@ -673,8 +673,8 @@ protected function match($pattern, $modifiers = '')
return preg_match(
"/^$pattern/$modifiers",
- $this->_input,
- $this->_lastMatches
+ $this->input,
+ $this->lastMatches
) ? true : false;
}
@@ -689,7 +689,7 @@ protected function consumeMatch()
//Make sure we don't consume matched newlines (We match for them sometimes)
//We need the newLine tokens and don't want them consumed here.
- $match = $this->_lastMatches[0] !== "\n" ? rtrim($this->_lastMatches[0], "\n") : $this->_lastMatches[0];
+ $match = $this->lastMatches[0] !== "\n" ? rtrim($this->lastMatches[0], "\n") : $this->lastMatches[0];
return $this->consume($this->strlen($match));
}
@@ -706,7 +706,7 @@ protected function consumeMatch()
protected function getMatch($index)
{
- return isset($this->_lastMatches[$index]) ? $this->_lastMatches[$index] : null;
+ return isset($this->lastMatches[$index]) ? $this->lastMatches[$index] : null;
}
/**
@@ -779,9 +779,9 @@ protected function createToken($type)
return [
'type' => $type,
- 'line' => $this->_line,
- 'level' => $this->_level,
- 'offset' => $this->_offset
+ 'line' => $this->line,
+ 'level' => $this->level,
+ 'offset' => $this->offset
];
}
@@ -811,7 +811,7 @@ protected function scanToken($type, $pattern, $modifiers = '')
$this->consumeMatch();
$token = $this->createToken($type);
- foreach ($this->_lastMatches as $key => $value) {
+ foreach ($this->lastMatches as $key => $value) {
//We append all STRING-Matches (?) to the token
if (is_string($key)) {
@@ -844,7 +844,7 @@ protected function scanToken($type, $pattern, $modifiers = '')
protected function scanIndent()
{
- if ($this->_offset !== 0 || !$this->match("([\t ]*)"))
+ if ($this->offset !== 0 || !$this->match("([\t ]*)"))
return;
$this->consumeMatch();
@@ -858,7 +858,7 @@ protected function scanIndent()
return;
}
- $oldLevel = $this->_level;
+ $oldLevel = $this->level;
if (!empty($indent)) {
$spaces = $this->strpos($indent, ' ') !== false;
@@ -867,14 +867,14 @@ protected function scanIndent()
if ($mixed) {
- switch ($this->_indentStyle) {
+ switch ($this->indentStyle) {
case self::INDENT_SPACE:
default:
//Convert tabs to spaces based on indentWidth
$spaces = str_replace(self::INDENT_TAB, str_repeat(
self::INDENT_SPACE,
- $this->_indentWidth ? $this->_indentWidth : 4
+ $this->indentWidth ? $this->indentWidth : 4
), $spaces);
$tabs = false;
$mixed = false;
@@ -884,7 +884,7 @@ protected function scanIndent()
//Convert spaces to tabs
$spaces = str_replace(self::INDENT_SPACE, str_repeat(
self::INDENT_TAB,
- $this->_indentWidth ? $this->_indentWidth : 1
+ $this->indentWidth ? $this->indentWidth : 1
), $spaces);
$spaces = false;
$mixed = false;
@@ -893,21 +893,21 @@ protected function scanIndent()
}
//Validate the indentation style
- $this->_indentStyle = $tabs ? self::INDENT_TAB : self::INDENT_SPACE;
+ $this->indentStyle = $tabs ? self::INDENT_TAB : self::INDENT_SPACE;
//Validate the indentation width
- if (!$this->_indentWidth)
+ if (!$this->indentWidth)
//We will use the pretty first indentation as our indent width
- $this->_indentWidth = $this->strlen($indent);
+ $this->indentWidth = $this->strlen($indent);
- $this->_level = intval(round($this->strlen($indent) / $this->_indentWidth));
+ $this->level = intval(round($this->strlen($indent) / $this->indentWidth));
- if ($this->_level > $oldLevel + 1)
- $this->_level = $oldLevel + 1;
+ if ($this->level > $oldLevel + 1)
+ $this->level = $oldLevel + 1;
} else
- $this->_level = 0;
+ $this->level = 0;
- $levels = $this->_level - $oldLevel;
+ $levels = $this->level - $oldLevel;
//Unchanged levels
if (!empty($indent) && $levels === 0)
@@ -931,8 +931,8 @@ protected function scanNewLine()
foreach ($this->scanToken('newLine', "\n") as $token) {
- $this->_line++;
- $this->_offset = 0;
+ $this->line++;
+ $this->offset = 0;
yield $token;
}
}
@@ -1693,6 +1693,7 @@ protected function scanAttributes()
$token['value'] = null;
$token['escaped'] = true;
$token['unchecked'] = false;
+ $spaces = null;
if ($this->match('((\.\.\.)?[a-zA-Z_][a-zA-Z0-9\-_:]*)', 'i')) {
@@ -1709,7 +1710,7 @@ protected function scanAttributes()
else {
$token['name'] = $this->getMatch(1);
- $this->read('ctype_space');
+ $spaces = $this->read('ctype_space');
}
}
@@ -1730,6 +1731,7 @@ protected function scanAttributes()
$token['unchecked'] = true;
$this->consume();
$char = $this->peek();
+ $spaces = null;
}
//Check escaping flag (!) if a name is given.
@@ -1740,6 +1742,7 @@ protected function scanAttributes()
$token['escaped'] = false;
$this->consume();
$char = $this->peek();
+ $spaces = null;
}
if (!$token['name'] || $char === '=') {
@@ -1757,10 +1760,17 @@ protected function scanAttributes()
$token['value'] = $token['value'] !== null
? $token['value'].$value
: $value;
+ $spaces = null;
}
yield $token;
+ if (!empty($spaces)) {
+
+ $continue = true;
+ continue;
+ }
+
if (in_array($this->peek(), $argSeparators, true)) {
$this->consume();
@@ -1803,7 +1813,8 @@ protected function scanAttributes()
protected function throwException($message)
{
- $message = "Failed to lex jade: $message (Line: {$this->_line}, Offset: {$this->_offset})";
+ $near = $this->isAtEnd() ? 'END' : $this->peek(10);
+ $message = "Failed to lex jade: $message (Line: {$this->line}, Offset: {$this->offset}, Near: `$near`)";
throw new Exception($message);
}
@@ -1823,7 +1834,7 @@ protected function strlen($string)
{
if (function_exists('mb_strlen'))
- return mb_strlen($string, $this->_options['encoding']);
+ return mb_strlen($string, $this->options['encoding']);
return strlen($string);
}
@@ -1846,7 +1857,7 @@ protected function strpos($haystack, $needle, $offset = null)
{
if (function_exists('mb_strpos'))
- return mb_strpos($haystack, $needle, $offset, $this->_options['encoding']);
+ return mb_strpos($haystack, $needle, $offset, $this->options['encoding']);
return strpos($haystack, $needle, $offset);
}
@@ -1869,7 +1880,7 @@ protected function substr($string, $start, $range = null)
{
if (function_exists('mb_substr'))
- return mb_substr($string, $start, $range, $this->_options['encoding']);
+ return mb_substr($string, $start, $range, $this->options['encoding']);
return substr($string, $start, $range);
}
@@ -1891,7 +1902,7 @@ protected function substr_count($haystack, $needle)
{
if (function_exists('mb_substr_count'))
- return mb_substr_count($haystack, $needle, $this->_options['encoding']);
+ return mb_substr_count($haystack, $needle, $this->options['encoding']);
return substr_count($haystack, $needle);
}
diff --git a/Lexer/Exception.php b/Lexer/Exception.php
index c8b93dc..545f28b 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.4.0
+ * @version 1.4.2
* @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.4.0
+ * @version 1.4.2
* @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 2d963c7..1693fc1 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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/files/Parser.html
* @since File available since Release 1.0
*/
@@ -58,7 +58,7 @@
* @author Talesoft
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
- * @version 1.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Parser.html
* @since File available since Release 1.0
*/
@@ -71,7 +71,7 @@ class Parser
*
* @var Lexer
*/
- private $_lexer;
+ private $lexer;
/**
* The level we're currently on.
@@ -82,21 +82,21 @@ class Parser
*
* @var int
*/
- private $_level;
+ private $level;
/**
* The Generator returned by the ->lex() method of the lexer.
*
* @var \Generator
*/
- private $_tokens;
+ private $tokens;
/**
* The root node of the currently parsed document.
*
* @var Node
*/
- private $_document;
+ private $document;
/**
* The parent that currently found childs are appended to.
@@ -106,7 +106,7 @@ class Parser
*
* @var Node
*/
- private $_currentParent;
+ private $currentParent;
/**
* The current element in the queue.
@@ -116,7 +116,7 @@ class Parser
*
* @var Node
*/
- private $_current;
+ private $current;
/**
* The last element that was completely put together.
@@ -125,7 +125,7 @@ class Parser
*
* @var Node
*/
- private $_last;
+ private $last;
/**
* States if we're in a mixin or not.
@@ -134,7 +134,7 @@ class Parser
*
* @var bool
*/
- private $_inMixin;
+ private $inMixin;
/**
* The level we're on inside a mixin.
@@ -143,14 +143,14 @@ class Parser
*
* @var int
*/
- private $_mixinLevel;
+ private $mixinLevel;
/**
* Stores an expanded node to attach it to the expanding node later.
*
* @var Node
*/
- private $_expansion;
+ private $expansion;
/**
@@ -175,7 +175,7 @@ public function __construct(array $options = null, Lexer $lexer = null)
$this->defineOptions(['lexerOptions' => []], $options);
- $this->_lexer = $lexer ? $lexer : new Lexer($this->_options['lexerOptions']);
+ $this->lexer = $lexer ? $lexer : new Lexer($this->options['lexerOptions']);
}
/**
@@ -186,7 +186,7 @@ public function __construct(array $options = null, Lexer $lexer = null)
public function getLexer()
{
- return $this->_lexer;
+ return $this->lexer;
}
/**
@@ -206,15 +206,15 @@ public function getLexer()
public function parse($input)
{
- $this->_level = 0;
- $this->_tokens = $this->_lexer->lex($input);
- $this->_document = $this->createNode('document', ['line' => 0, 'offset' => 0]);
- $this->_currentParent = $this->_document;
- $this->_current = null;
- $this->_last = null;
- $this->_inMixin = false;
- $this->_mixinLevel = null;
- $this->_expansion = null;
+ $this->level = 0;
+ $this->tokens = $this->lexer->lex($input);
+ $this->document = $this->createNode('document', ['line' => 0, 'offset' => 0]);
+ $this->currentParent = $this->document;
+ $this->current = null;
+ $this->last = null;
+ $this->inMixin = false;
+ $this->mixinLevel = null;
+ $this->expansion = null;
//Fix HHVM generators needing ->next() before ->current()
//This will actually work as expected, no node will be skipped
@@ -222,7 +222,7 @@ public function parse($input)
//expected behaviour)
if (defined('HHVM_VERSION')) {
- $this->_tokens->next();
+ $this->tokens->next();
}
//While we have tokens, handle current token, then go to next token
@@ -234,7 +234,7 @@ public function parse($input)
}
//Return the final document node with all its awesome child nodes
- return $this->_document;
+ return $this->document;
}
/**
@@ -401,7 +401,7 @@ protected function expectEnd(array $relatedToken = null)
protected function hasTokens()
{
- return $this->_tokens->valid();
+ return $this->tokens->valid();
}
/**
@@ -416,7 +416,7 @@ protected function hasTokens()
protected function nextToken()
{
- $this->_tokens->next();
+ $this->tokens->next();
return $this;
}
@@ -431,7 +431,7 @@ protected function nextToken()
protected function getToken()
{
- return $this->_tokens->current();
+ return $this->tokens->current();
}
@@ -455,7 +455,7 @@ protected function getToken()
protected function createNode($type, array $token = null)
{
- $token = $token ? $token : ['line' => $this->_lexer->getLine(), 'offset' => $this->_lexer->getOffset()];
+ $token = $token ? $token : ['line' => $this->lexer->getLine(), 'offset' => $this->lexer->getOffset()];
$node = new Node($type, $token['line'], $token['offset']);
return $node;
@@ -499,24 +499,24 @@ protected function createElement(array $token = null)
protected function handleAssignment(array $token)
{
- if (!$this->_current)
- $this->_current = $this->createElement();
+ if (!$this->current)
+ $this->current = $this->createElement();
- if (!in_array($this->_current->type, ['element', 'mixinCall']))
+ if (!in_array($this->current->type, ['element', 'mixinCall']))
$this->throwException(
"Assignments can only happen on elements and mixinCalls"
);
$node = $this->createNode('assignment', $token);
$node->name = $token['name'];
- $this->_current->assignments[] = $node;
+ $this->current->assignments[] = $node;
if ($this->expectNext(['attributeStart'])) {
- $element = $this->_current;
- $this->_current = $node;
+ $element = $this->current;
+ $this->current = $node;
$this->handleToken();
- $this->_current = $element;
+ $this->current = $element;
} else
$this->throwException(
"Assignments require a parameter block"
@@ -539,8 +539,8 @@ protected function handleAssignment(array $token)
protected function handleAttribute(array $token)
{
- if (!$this->_current)
- $this->_current = $this->createElement();
+ if (!$this->current)
+ $this->current = $this->createElement();
$node = $this->createNode('attribute', $token);
$node->name = $token['name'];
@@ -548,16 +548,16 @@ protected function handleAttribute(array $token)
$node->escaped = $token['escaped'];
$node->unchecked = $token['unchecked'];
- if (!$node->name && in_array($this->_current->type, ['element', 'mixin']))
+ if (!$node->name && in_array($this->current->type, ['element', 'mixin']))
$this->throwException('Attributes in elements and mixins need a name', $token);
- if ($this->_current->type === 'mixinCall' && !$node->value) {
+ if ($this->current->type === 'mixinCall' && !$node->value) {
$node->value = $node->name;
$node->name = null;
}
- $this->_current->attributes[] = $node;
+ $this->current->attributes[] = $node;
}
/**
@@ -576,10 +576,10 @@ protected function handleAttribute(array $token)
protected function handleAttributeStart(array $token)
{
- if (!$this->_current)
- $this->_current = $this->createElement();
+ if (!$this->current)
+ $this->current = $this->createElement();
- if (!in_array($this->_current->type, ['element', 'assignment', 'import', 'variable', 'mixin', 'mixinCall']))
+ if (!in_array($this->current->type, ['element', 'assignment', 'import', 'variable', 'mixin', 'mixinCall']))
$this->throwException(
"Attributes can only be placed on element, assignment, import, variable, mixin and mixinCall"
);
@@ -624,12 +624,12 @@ protected function handleBlock(array $token)
$node->name = isset($token['name']) ? $token['name'] : null;
$node->mode = isset($token['mode']) ? $token['mode'] : null;
- if (!$node->name && !$this->_inMixin)
+ if (!$node->name && !$this->inMixin)
$this->throwException(
"Blocks outside a mixin always need a name"
);
- $this->_current = $node;
+ $this->current = $node;
$this->expectEnd($token);
}
@@ -651,17 +651,17 @@ protected function handleBlock(array $token)
protected function handleClass(array $token)
{
- if (!$this->_current)
- $this->_current = $this->createElement();
+ if (!$this->current)
+ $this->current = $this->createElement();
- if (!in_array($this->_current->type, ['element', 'mixinCall']))
+ if (!in_array($this->current->type, ['element', 'mixinCall']))
$this->throwException("Classes can only be used on elements and mixin calls", $token);
$attr = $this->createNode('attribute', $token);
$attr->name = 'class';
$attr->value = $token['name'];
$attr->escaped = false;
- $this->_current->attributes[] = $attr;
+ $this->current->attributes[] = $attr;
}
/**
@@ -677,7 +677,7 @@ protected function handleComment(array $token)
$node = $this->createNode('comment', $token);
$node->rendered = $token['rendered'];
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -690,7 +690,7 @@ protected function handleCase(array $token)
$node = $this->createNode('case', $token);
$node->subject = $token['subject'];
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -705,7 +705,7 @@ protected function handleConditional(array $token)
$node->subject = $token['subject'];
$node->conditionType = $token['conditionType'];
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -717,7 +717,7 @@ protected function handleDo(array $token)
{
$node = $this->createNode('do', $token);
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -731,7 +731,7 @@ protected function handleDoctype(array $token)
$node = $this->createNode('doctype', $token);
$node->name = $token['name'];
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -747,7 +747,7 @@ protected function handleEach(array $token)
$node->itemName = $token['itemName'];
$node->keyName = isset($token['keyName']) ? $token['keyName'] : null;
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -769,10 +769,10 @@ protected function handleExpression(array $token)
$node->unchecked = $token['unchecked'];
$node->value = $token['value'];
- if ($this->_current)
- $this->_current->append($node);
+ if ($this->current)
+ $this->current->append($node);
else
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -789,7 +789,7 @@ protected function handleCode(array $token)
$node->value = $token['value'];
$node->block = $token['block'];
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -802,7 +802,7 @@ protected function handleFilter(array $token)
$node = $this->createNode('filter', $token);
$node->name = $token['name'];
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -821,17 +821,17 @@ protected function handleFilter(array $token)
protected function handleId(array $token)
{
- if (!$this->_current)
- $this->_current = $this->createElement();
+ if (!$this->current)
+ $this->current = $this->createElement();
- if (!in_array($this->_current->type, ['element', 'mixinCall']))
+ if (!in_array($this->current->type, ['element', 'mixinCall']))
$this->throwException("IDs can only be used on elements and mixin calls", $token);
$attr = $this->createNode('attribute', $token);
$attr->name = 'id';
$attr->value = $token['name'];
$attr->escaped = false;
- $this->_current->attributes[] = $attr;
+ $this->current->attributes[] = $attr;
}
/**
@@ -847,7 +847,7 @@ protected function handleVariable(array $token)
$node = $this->createNode('variable');
$node->name = $token['name'];
$node->attributes = [];
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -867,7 +867,7 @@ protected function handleVariable(array $token)
protected function handleImport(array $token)
{
- if ($token['importType'] === 'extends' && count($this->_document->children) > 0)
+ if ($token['importType'] === 'extends' && count($this->document->children) > 0)
$this->throwException(
"extends should be the very first statement in a document",
$token
@@ -880,7 +880,7 @@ protected function handleImport(array $token)
$node->attributes = [];
$node->assignments = [];
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -907,18 +907,18 @@ protected function handleImport(array $token)
protected function handleIndent(array $token = null)
{
- $this->_level++;
+ $this->level++;
- if (!$this->_last)
+ if (!$this->last)
return;
- if (in_array($this->_last->type, ['import', 'expression', 'doctype']))
+ if (in_array($this->last->type, ['import', 'expression', 'doctype']))
$this->throwException(
- 'The '.$this->_last->type.' instruction can\'t have children',
+ 'The '.$this->last->type.' instruction can\'t have children',
$token
);
- $this->_currentParent = $this->_last;
+ $this->currentParent = $this->last;
}
/**
@@ -937,16 +937,16 @@ protected function handleIndent(array $token = null)
protected function handleTag(array $token)
{
- if (!$this->_current)
- $this->_current = $this->createElement();
+ if (!$this->current)
+ $this->current = $this->createElement();
- if ($this->_current->type !== 'element')
+ if ($this->current->type !== 'element')
$this->throwException("Tags can only be used on elements", $token);
- if ($this->_current->tag)
+ if ($this->current->tag)
$this->throwException('This element already has a tag name', $token);
- $this->_current->tag = $token['name'];
+ $this->current->tag = $token['name'];
}
/**
@@ -963,7 +963,7 @@ protected function handleTag(array $token)
protected function handleMixin(array $token)
{
- if ($this->_inMixin)
+ if ($this->inMixin)
$this->throwException(
"Failed to define mixin: Mixins cant be nested"
);
@@ -973,10 +973,10 @@ protected function handleMixin(array $token)
$node->attributes = [];
$node->assignments = [];
- $this->_inMixin = true;
- $this->_mixinLevel = $this->_level;
+ $this->inMixin = true;
+ $this->mixinLevel = $this->level;
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -992,7 +992,7 @@ protected function handleMixinCall(array $token)
$node->attributes = [];
$node->assignments = [];
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -1011,20 +1011,20 @@ protected function handleMixinCall(array $token)
protected function handleNewLine()
{
- if ($this->_current) {
+ if ($this->current) {
//Is there any expansion?
- if ($this->_expansion) {
+ if ($this->expansion) {
//Tell the current element who expands it
- $this->_current->expands = $this->_expansion;
- $this->_expansion = null;
+ $this->current->expands = $this->expansion;
+ $this->expansion = null;
}
//Append to current parent
- $this->_currentParent->append($this->_current);
- $this->_last = $this->_current;
- $this->_current = null;
+ $this->currentParent->append($this->current);
+ $this->last = $this->current;
+ $this->current = null;
}
}
@@ -1044,14 +1044,14 @@ protected function handleNewLine()
protected function handleOutdent()
{
- $this->_level--;
+ $this->level--;
- $this->_currentParent = $this->_currentParent->parent;
+ $this->currentParent = $this->currentParent->parent;
- if ($this->_inMixin && $this->_level <= $this->_mixinLevel) {
+ if ($this->inMixin && $this->level <= $this->mixinLevel) {
- $this->_inMixin = false;
- $this->_mixinLevel = null;
+ $this->inMixin = false;
+ $this->mixinLevel = null;
}
}
@@ -1079,13 +1079,13 @@ protected function handleOutdent()
protected function handleExpansion(array $token)
{
- if (!$this->_current)
+ if (!$this->current)
$this->throwException(
"Expansion needs an element to work on",
$token
);
- if ($this->_current->type === 'element' && !$token['withSpace']) {
+ if ($this->current->type === 'element' && !$token['withSpace']) {
if (!$this->expectNext(['tag'])) {
$this->throwException(
@@ -1099,16 +1099,16 @@ protected function handleExpansion(array $token)
}
$token = $this->getToken();
- $this->_current->tag .= ':'.$token['name'];
+ $this->current->tag .= ':'.$token['name'];
return;
}
- if ($this->_expansion)
- $this->_current->expands = $this->_expansion;
+ if ($this->expansion)
+ $this->current->expands = $this->expansion;
- $this->_expansion = $this->_current;
- $this->_current = null;
+ $this->expansion = $this->current;
+ $this->current = null;
}
@@ -1128,11 +1128,11 @@ protected function handleText(array $token)
$node->level = $token['level'];
$node->escaped = $token['escaped'];
- if ($this->_current) {
+ if ($this->current) {
- $this->_current->append($node);
+ $this->current->append($node);
} else
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -1146,7 +1146,7 @@ protected function handleWhen(array $token)
$node = $this->createNode('when', $token);
$node->subject = $token['subject'];
$node->default = $token['default'];
- $this->_current = $node;
+ $this->current = $node;
}
/**
@@ -1159,7 +1159,7 @@ protected function handleWhile(array $token)
$node = $this->createNode('while', $token);
$node->subject = $token['subject'];
- $this->_current = $node;
+ $this->current = $node;
}
@@ -1173,7 +1173,7 @@ protected function handleFor(array $token)
$node = $this->createNode('for', $token);
$node->subject = $token['subject'];
- $this->_current = $node;
+ $this->current = $node;
}
diff --git a/Parser/Exception.php b/Parser/Exception.php
index cd2aafc..203fe99 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.4.0
+ * @version 1.4.2
* @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.4.0
+ * @version 1.4.2
* @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 56f9f83..4557686 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.4.0
+ * @version 1.4.2
* @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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Parser.Node.html
* @since File available since Release 1.0
*/
@@ -89,7 +89,7 @@ class Node
*
* @var array
*/
- private $_data;
+ private $data;
/**
* Creates a new, detached node without children or a parent.
@@ -114,7 +114,7 @@ public function __construct($type, $line = null, $offset = null)
$this->parent = null;
$this->children = [];
- $this->_data = [];
+ $this->data = [];
}
/**
@@ -455,7 +455,7 @@ public function dump($level = 0)
: '{'.implode(', ', array_map('trim', array_map('strval', $value))).'}';
return $str;
- }, array_keys($this->_data), $this->_data));
+ }, array_keys($this->data), $this->data));
$indent = str_repeat(' ', $level);
$str = $indent.'['.$this->type.(empty($export) ? '' : " $export").']'."\n";
@@ -477,7 +477,7 @@ public function dump($level = 0)
public function __isset($key)
{
- return isset($this->_data[$key]);
+ return isset($this->data[$key]);
}
/**
@@ -490,7 +490,7 @@ public function __isset($key)
public function __unset($key)
{
- unset($this->_data[$key]);
+ unset($this->data[$key]);
}
/**
@@ -505,7 +505,7 @@ public function __unset($key)
public function &__get($key)
{
- return $this->_data[$key];
+ return $this->data[$key];
}
/**
@@ -519,7 +519,7 @@ public function &__get($key)
public function __set($key, $value)
{
- $this->_data[$key] = $value;
+ $this->data[$key] = $value;
}
/**
diff --git a/Renderer.php b/Renderer.php
index fb78617..d942b11 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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/files/Renderer.html
* @since File available since Release 1.0
*/
@@ -52,7 +52,7 @@
* @author Talesoft
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
- * @version 1.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.html
* @since File available since Release 1.0
*/
@@ -65,28 +65,28 @@ class Renderer
*
* @var Compiler
*/
- private $_compiler;
+ private $compiler;
/**
* The parser that is used in this renderer instance.
*
* @var Parser
*/
- private $_parser;
+ private $parser;
/**
* The lexer that is used in this renderer instance.
*
* @var Lexer
*/
- private $_lexer;
+ private $lexer;
/**
* The adapter that actually renders the files in a dynamic manner.
*
* @var AdapterBase
*/
- private $_adapter;
+ private $adapter;
/**
* Creates a new Tale Jade Renderer instance to render Jade files.
@@ -144,9 +144,9 @@ public function __construct(
$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'], $this->_lexer);
- $this->_compiler = $compiler ? $compiler : new Compiler($this->_options['compilerOptions'], $this->_parser);
+ $this->lexer = $lexer ? $lexer : new Lexer($this->options['lexerOptions']);
+ $this->parser = $parser ? $parser : new Parser($this->options['parserOptions'], $this->lexer);
+ $this->compiler = $compiler ? $compiler : new Compiler($this->options['compilerOptions'], $this->parser);
}
/**
@@ -157,7 +157,7 @@ public function __construct(
public function getCompiler()
{
- return $this->_compiler;
+ return $this->compiler;
}
/**
@@ -168,7 +168,7 @@ public function getCompiler()
public function getParser()
{
- return $this->_parser;
+ return $this->parser;
}
/**
@@ -179,7 +179,7 @@ public function getParser()
public function getLexer()
{
- return $this->_lexer;
+ return $this->lexer;
}
/**
@@ -241,11 +241,11 @@ public function addFilter($name, $callback)
public function getAdapter()
{
- if (!isset($this->_adapter)) {
+ if (!isset($this->adapter)) {
- $adapter = $this->_options['adapter'];
+ $adapter = $this->options['adapter'];
$className = strpos($adapter, '\\') === false
- ? __NAMESPACE__.'\\Renderer\\Adapter\\'.ucfirst($this->_options['adapter'])
+ ? __NAMESPACE__.'\\Renderer\\Adapter\\'.ucfirst($this->options['adapter'])
: $adapter;
if (!class_exists($className))
@@ -258,10 +258,10 @@ public function getAdapter()
"The passed adapter doesnt extend Tale\\Jade\\Renderer\\AdapterBase"
);
- $this->_adapter = new $className($this, $this->_options['adapterOptions']);
+ $this->adapter = new $className($this, $this->options['adapterOptions']);
}
- return $this->_adapter;
+ return $this->adapter;
}
/**
@@ -287,7 +287,7 @@ public function getAdapter()
public function compile($input, $path = null)
{
- return $this->_compiler->compile($input, $path);
+ return $this->compiler->compile($input, $path);
}
/**
@@ -309,7 +309,7 @@ public function compile($input, $path = null)
public function compileFile($path)
{
- return $this->_compiler->compileFile($path);
+ return $this->compiler->compileFile($path);
}
/**
diff --git a/Renderer/Adapter/File.php b/Renderer/Adapter/File.php
index 7b98376..9671ed5 100644
--- a/Renderer/Adapter/File.php
+++ b/Renderer/Adapter/File.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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/files/Renderer.Adapter.File.html
* @since File available since Release 1.0
*/
@@ -59,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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.Adapter.File.html
* @since File available since Release 1.0
*/
diff --git a/Renderer/Adapter/Stream.php b/Renderer/Adapter/Stream.php
index 3a65cd7..3002611 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.4.0
+ * @version 1.4.2
* @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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.Adapter.Stream.html
* @since File available since Release 1.0
*/
diff --git a/Renderer/Adapter/Stream/Wrapper.php b/Renderer/Adapter/Stream/Wrapper.php
index ef4fc52..8d992d8 100644
--- a/Renderer/Adapter/Stream/Wrapper.php
+++ b/Renderer/Adapter/Stream/Wrapper.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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/files/Renderer.Adapter.Stream.Wrapper.html
* @since File available since Release 1.0
*/
@@ -42,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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.Adapter.Stream.Wrapper.html
* @since File available since Release 1.0
*/
@@ -54,21 +54,21 @@ class Wrapper
*
* @var string
*/
- private $_data;
+ private $data;
/**
* The current position in our $_data.
*
* @var int
*/
- private $_position;
+ private $position;
/**
* The length of our $_data.
*
* @var int
*/
- private $_length;
+ private $length;
/**
* This gets called when a url-stream is opened with the wrapper-scheme.
@@ -96,10 +96,10 @@ public function stream_open($uri, $mode, $options, &$opened_path)
//
//We decode that and $_data will contain only the pure, compiled PHTML
//ready for inclusion
- $this->_data = base64_decode($substr($uri, $strpos($uri, ';') + 1));
+ $this->data = base64_decode($substr($uri, $strpos($uri, ';') + 1));
- $this->_position = 0;
- $this->_length = $strlen($this->_data);
+ $this->position = 0;
+ $this->length = $strlen($this->data);
return true;
}
@@ -125,8 +125,8 @@ public function stream_read($length)
$strlen = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen';
//Read that stuff chunk by chunk (whatever buffersize there is)
- $result = $substr($this->_data, $this->_position, $length);
- $this->_position += $strlen($result);
+ $result = $substr($this->data, $this->position, $length);
+ $this->position += $strlen($result);
return $result;
}
@@ -141,7 +141,7 @@ public function stream_read($length)
public function stream_tell()
{
- return $this->_position;
+ return $this->position;
}
/**
@@ -155,7 +155,7 @@ public function stream_tell()
public function stream_eof()
{
- return $this->_position >= $this->_length;
+ return $this->position >= $this->length;
}
/**
diff --git a/Renderer/AdapterBase.php b/Renderer/AdapterBase.php
index 1a9ed08..b002f93 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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/files/Renderer.AdapterBase.html
* @since File available since Release 1.0
*/
@@ -41,7 +41,7 @@
* @author Talesoft
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
- * @version 1.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.AdapterBase.html
* @since File available since Release 1.0
*/
@@ -54,7 +54,7 @@ abstract class AdapterBase
*
* @var Renderer
*/
- private $_renderer;
+ private $renderer;
/**
@@ -76,7 +76,7 @@ abstract class AdapterBase
public function __construct(Renderer $renderer, array $options = null)
{
- $this->_renderer = $renderer;
+ $this->renderer = $renderer;
if ($options)
$this->setOptions($options);
@@ -90,7 +90,7 @@ public function __construct(Renderer $renderer, array $options = null)
public function getRenderer()
{
- return $this->_renderer;
+ return $this->renderer;
}
/**
diff --git a/Test/AntiTest.php b/Test/AntiTest.php
index efa9e66..71a9a57 100644
--- a/Test/AntiTest.php
+++ b/Test/AntiTest.php
@@ -10,40 +10,40 @@ class AntiTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Compiler */
- private $_compiler;
+ private $compiler;
public function setUp()
{
- $this->_compiler = new Compiler();
+ $this->compiler = new Compiler();
}
public function testWhenNotCaseChild()
{
$this->setExpectedException(Compiler\Exception::class);
- $this->_compiler->compile('when "abc"');
+ $this->compiler->compile('when "abc"');
}
public function testUnclosedAttributeBlockOnElement()
{
$this->setExpectedException(Compiler\Exception::class);
- $this->_compiler->compile('some-element(abc, def');
+ $this->compiler->compile('some-element(abc, def');
}
public function testUnclosedAttributeBlockOnMixin()
{
$this->setExpectedException(Compiler\Exception::class);
- $this->_compiler->compile('mixin some-mixin(abc, def');
+ $this->compiler->compile('mixin some-mixin(abc, def');
}
public function testUnclosedAttributeBlockOnMixinCall()
{
$this->setExpectedException(Compiler\Exception::class);
- $this->_compiler->compile('+some-mixin(abc, def');
+ $this->compiler->compile('+some-mixin(abc, def');
}
public function testNestedMixin()
@@ -51,21 +51,21 @@ public function testNestedMixin()
$this->setExpectedException(Compiler\Exception::class);
- $this->_compiler->compile("mixin some-mixin()\n\tmixin some-sub-mixin()");
+ $this->compiler->compile("mixin some-mixin()\n\tmixin some-sub-mixin()");
}
public function testDoWithoutWhile()
{
$this->setExpectedException(Compiler\Exception::class);
- $this->_compiler->compile("do\n\tp Something\nnot-a-while-element");
+ $this->compiler->compile("do\n\tp Something\nnot-a-while-element");
}
public function testStandaloneWhile()
{
$this->setExpectedException(Compiler\Exception::class);
- $this->_compiler->compile("while \$something");
+ $this->compiler->compile("while \$something");
}
public function testDoWhileWithWhileChildren()
@@ -73,6 +73,6 @@ public function testDoWhileWithWhileChildren()
$this->setExpectedException(Compiler\Exception::class);
- $this->_compiler->compile("do\n\tp Something\nwhile \$something\n\tp Anything");
+ $this->compiler->compile("do\n\tp Something\nwhile \$something\n\tp Anything");
}
}
\ No newline at end of file
diff --git a/Test/AttributeTest.php b/Test/AttributeTest.php
index cb38a2d..de06f3a 100644
--- a/Test/AttributeTest.php
+++ b/Test/AttributeTest.php
@@ -10,15 +10,18 @@ class AttributeTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Renderer */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/attributes'
],
+ 'compilerOptions' => [
+ 'echoXmlDoctype' => false
+ ],
'pretty' => false,
'paths' => [__DIR__.'/views/attributes']
]);
@@ -27,31 +30,31 @@ public function setUp()
public function testNumberValue()
{
- $this->assertEquals(' ', $this->_renderer->compile('a(href=some-literal-value)'));
+ $this->assertEquals(' ', $this->renderer->compile('a(href=some-literal-value)'));
}
public function testSingleQuotedValue()
{
- $this->assertEquals(' ', $this->_renderer->compile('a(href=\'some value\')'));
+ $this->assertEquals(' ', $this->renderer->compile('a(href=\'some value\')'));
}
public function testDoubleQuotedValue()
{
- $this->assertEquals(' ', $this->_renderer->compile('a(href="some value")'));
+ $this->assertEquals(' ', $this->renderer->compile('a(href="some value")'));
}
public function testDoubleColonName()
{
- $this->assertEquals(' ', $this->_renderer->compile('a(ns:sub-ns:href="some value")'));
+ $this->assertEquals(' ', $this->renderer->compile('a(ns:sub-ns:href="some value")'));
}
public function testLiteralValue()
{
- $this->assertEquals(' ', $this->_renderer->compile('a(href=1337)'));
+ $this->assertEquals(' ', $this->renderer->compile('a(href=1337)'));
}
public function testSingleVariableExpression()
@@ -59,7 +62,7 @@ public function testSingleVariableExpression()
$this->assertEquals(
'> ',
- $this->_renderer->compile('a(href=$url)')
+ $this->renderer->compile('a(href=$url)')
);
}
@@ -68,7 +71,7 @@ public function testCrossAssignment()
$this->assertEquals(
'
',
- $this->_renderer->render('cross-assignments', [
+ $this->renderer->render('cross-assignments', [
'externAttrs' => [
'class' => ['second', 'third', ['fourth', 'fifth']],
'style' => [
@@ -85,19 +88,19 @@ public function testCrossAssignment()
public function testRepeation()
{
- $this->assertEquals(' ', $this->_renderer->compile('a(href="first", href=\'second\')'));
+ $this->assertEquals(' ', $this->renderer->compile('a(href="first", href=\'second\')'));
}
public function testClassRepeation()
{
- $this->assertEquals(' ', $this->_renderer->compile('a(class="first", class=\'second\')'));
+ $this->assertEquals(' ', $this->renderer->compile('a(class="first", class=\'second\')'));
}
public function testStyleRepeation()
{
- $this->assertEquals(' ', $this->_renderer->compile(
+ $this->assertEquals(' ', $this->renderer->compile(
'a(style="first: first-value", style=\'second: second-value\')'
));
}
@@ -108,7 +111,7 @@ public function testStyleRepeation()
public function testAttributeValues($value, $expected)
{
- $this->assertEquals($expected, $this->_renderer->render(
+ $this->assertEquals($expected, $this->renderer->render(
'single-value',
['value' => $value]
));
@@ -134,19 +137,21 @@ public function testUnnamedAttributed()
{
$this->setExpectedException(Compiler\Exception::class);
- $this->assertEquals('', $this->_renderer->compile('a(="some value")'));
+ $this->assertEquals('', $this->renderer->compile('a(="some value")'));
}
public function testExpectedButNotGivenValue()
{
- $this->assertEquals(' ', $this->_renderer->compile('a(href=)'));
+ $this->assertEquals(' ', $this->renderer->compile("doctype html\na(href=)"));
+ $this->assertEquals(' ', $this->renderer->compile("doctype default\na(href=)"));
+ $this->assertEquals(' ', $this->renderer->compile("doctype xml\na(href=)"));
}
public function testSpaceSeparated()
{
- $this->assertEquals(' ', $this->_renderer->render(
+ $this->assertEquals(' ', $this->renderer->render(
'space-separated'
));
}
diff --git a/Test/BlockExpansionTest.php b/Test/BlockExpansionTest.php
index c13afab..d5b382b 100644
--- a/Test/BlockExpansionTest.php
+++ b/Test/BlockExpansionTest.php
@@ -9,38 +9,38 @@ class BlockExpansionTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Compiler */
- private $_compiler;
+ private $compiler;
public function setUp()
{
- $this->_compiler = new Compiler();
+ $this->compiler = new Compiler();
}
public function testTagExansion()
{
- $this->assertEquals(' ', $this->_compiler->compile('a: b: c: d: e'));
+ $this->assertEquals(' ', $this->compiler->compile('a: b: c: d: e'));
}
public function testClassExpansion()
{
- $this->assertEquals('', $this->_compiler->compile('.a: .b: .c: .d: .e'));
+ $this->assertEquals('', $this->compiler->compile('.a: .b: .c: .d: .e'));
}
public function testIdExpansion()
{
- $this->assertEquals('', $this->_compiler->compile('#a: #b: #c: #d: #e'));
+ $this->assertEquals('', $this->compiler->compile('#a: #b: #c: #d: #e'));
}
public function testMixedExpansion()
{
- $this->assertEquals(' ', $this->_compiler->compile('nav: ul.main-menu: li.active: a#start(href="start")'));
+ $this->assertEquals(' ', $this->compiler->compile('nav: ul.main-menu: li.active: a#start(href="start")'));
}
public function testIfExpansion()
{
- $this->assertEquals('Hello =htmlentities(isset($someVar) ? $someVar : \'\', \ENT_QUOTES, \'UTF-8\')?>!
', $this->_compiler->compile('if $someVar: p Hello #{$someVar}!'));
- $this->assertEquals('Hello =htmlentities(isset($someVar) ? $someVar : \'\', \ENT_QUOTES, \'UTF-8\')?>!
', $this->_compiler->compile('if (isset($someVar) ? $someVar : \'abc\'): p Hello #{$someVar}!'));
+ $this->assertEquals('Hello =htmlentities(isset($someVar) ? $someVar : \'\', \ENT_QUOTES, \'UTF-8\')?>!
', $this->compiler->compile('if $someVar: p Hello #{$someVar}!'));
+ $this->assertEquals('Hello =htmlentities(isset($someVar) ? $someVar : \'\', \ENT_QUOTES, \'UTF-8\')?>!
', $this->compiler->compile('if (isset($someVar) ? $someVar : \'abc\'): p Hello #{$someVar}!'));
}
public function testComplexExpansion()
@@ -56,6 +56,6 @@ public function testComplexExpansion()
f: g: h
JADE;
- $this->assertEquals(' ', $this->_compiler->compile($jade));
+ $this->assertEquals(' ', $this->compiler->compile($jade));
}
}
\ No newline at end of file
diff --git a/Test/BlockTest.php b/Test/BlockTest.php
index f288230..ce2f136 100644
--- a/Test/BlockTest.php
+++ b/Test/BlockTest.php
@@ -8,12 +8,12 @@ class BlockTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Compiler */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/blocks'
],
@@ -25,7 +25,7 @@ public function setUp()
public function testAppend()
{
- $this->assertEquals('Element 1
Element 2
Element 3
', $this->_renderer->render(
+ $this->assertEquals('Element 1
Element 2
Element 3
', $this->renderer->render(
'append'
));
}
@@ -33,7 +33,7 @@ public function testAppend()
public function testPrepend()
{
- $this->assertEquals('Element 3
Element 2
Element 1
', $this->_renderer->render(
+ $this->assertEquals('Element 3
Element 2
Element 1
', $this->renderer->render(
'prepend'
));
}
@@ -41,7 +41,7 @@ public function testPrepend()
public function testReplace()
{
- $this->assertEquals('Element 4
Element 5
Element 6
', $this->_renderer->render(
+ $this->assertEquals('Element 4
Element 5
Element 6
', $this->renderer->render(
'replace'
));
}
diff --git a/Test/ClassTest.php b/Test/ClassTest.php
index f2728ae..2182716 100644
--- a/Test/ClassTest.php
+++ b/Test/ClassTest.php
@@ -8,18 +8,18 @@ class ClassTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Compiler */
- private $_compiler;
+ private $compiler;
public function setUp()
{
- $this->_compiler = new Compiler();
+ $this->compiler = new Compiler();
}
public function testClass()
{
- $this->assertEquals('Test
', $this->_compiler->compile('.test Test'));
+ $this->assertEquals('Test
', $this->compiler->compile('.test Test'));
}
public function testNestedClass()
@@ -30,13 +30,13 @@ public function testNestedClass()
.test-child Test
JADE;
- $this->assertEquals('', $this->_compiler->compile($jade));
+ $this->assertEquals('', $this->compiler->compile($jade));
}
public function testTagClassCombination()
{
- $this->assertEquals('Test
', $this->_compiler->compile('p.test Test'));
+ $this->assertEquals('Test
', $this->compiler->compile('p.test Test'));
}
public function testNestedTagClassCombination()
@@ -47,7 +47,7 @@ public function testNestedTagClassCombination()
p.test-child Test
JADE;
- $this->assertEquals('', $this->_compiler->compile($jade));
+ $this->assertEquals('', $this->compiler->compile($jade));
}
public function testComplexTagClassCombination()
@@ -81,6 +81,6 @@ public function testComplexTagClassCombination()
a.test-link
JADE;
- $this->assertEquals('
', $this->_compiler->compile($jade));
+ $this->assertEquals('
', $this->compiler->compile($jade));
}
}
\ No newline at end of file
diff --git a/Test/ConditionalTest.php b/Test/ConditionalTest.php
index 6ec3101..4c9c445 100644
--- a/Test/ConditionalTest.php
+++ b/Test/ConditionalTest.php
@@ -9,12 +9,12 @@ class ConditionalTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Renderer */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/conditionals'
],
@@ -26,7 +26,7 @@ public function setUp()
public function testIfCompilation()
{
- $this->assertEquals('Do something
', $this->_renderer->compile('if $something
+ $this->assertEquals('Do something
', $this->renderer->compile('if $something
p Do something'));
}
@@ -35,14 +35,14 @@ public function testIfRendering()
$this->assertEquals(
'1 This should be printed
4 This should be printed
5 This should be printed
6 This should be printed
9 This should be printed
',
- $this->_renderer->render('if', ['condition' => true, 'negativeCondition' => false])
+ $this->renderer->render('if', ['condition' => true, 'negativeCondition' => false])
);
}
public function testUnlessCompilation()
{
- $this->assertEquals('Do something
', $this->_renderer->compile('unless $something
+ $this->assertEquals('Do something
', $this->renderer->compile('unless $something
p Do something'));
}
@@ -51,7 +51,7 @@ public function testUnlessRendering()
$this->assertEquals(
'2 This should be printed
3 This should be printed
',
- $this->_renderer->render('unless', ['condition' => true, 'negativeCondition' => false])
+ $this->renderer->render('unless', ['condition' => true, 'negativeCondition' => false])
);
}
@@ -60,7 +60,7 @@ public function testIfElseCompilation()
$this->assertEquals(
'Do something
Do some other thing
',
- $this->_renderer->compile('if $something
+ $this->renderer->compile('if $something
p Do something
else
p Do some other thing'));
@@ -71,7 +71,7 @@ public function testIfElseRendering()
$this->assertEquals(
'1 This should be printed
4 This should be printed
',
- $this->_renderer->render('if-else', ['condition' => true, 'negativeCondition' => false])
+ $this->renderer->render('if-else', ['condition' => true, 'negativeCondition' => false])
);
}
@@ -97,7 +97,7 @@ public function testIssue19()
$this->assertEquals(
' \'Issues\', \'url\' => [\'/issue/index\']]?>user->isGuest) {?> \'Login\', \'url\' => [\'/site/login\']]?> \'Users\', \'url\' => [\'/user/index\']]?> \'Gii\', \'url\' => [\'/gii\']]?>
',
- $this->_renderer->compile($jade)
+ $this->renderer->compile($jade)
);
@@ -118,7 +118,7 @@ public function testIssue19()
$this->assertEquals(
' \'Issues\', \'url\' => [\'/issue/index\']]?>user->isGuest) {?> \'Login\', \'url\' => [\'/site/login\']]?> \'Users\', \'url\' => [\'/user/index\']]?> \'Gii\', \'url\' => [\'/gii\']]?>
',
- $this->_renderer->compile($jade)
+ $this->renderer->compile($jade)
);
@@ -140,7 +140,7 @@ public function testIssue19()
$this->assertEquals(
' \'Issues\', \'url\' => [\'/issue/index\']]?>user->isGuest) {?> \'Login\', \'url\' => [\'/site/login\']]?> \'Users\', \'url\' => [\'/user/index\']]?> \'Gii\', \'url\' => [\'/gii\']]?>
',
- $this->_renderer->compile($jade)
+ $this->renderer->compile($jade)
);
}
@@ -179,7 +179,7 @@ public function testIssue18()
$this->assertEquals(
'Do something
Do some random stuff
and it goes on normally...
',
- $this->_renderer->compile($jade)
+ $this->renderer->compile($jade)
);
}
}
\ No newline at end of file
diff --git a/Test/DoctypeTest.php b/Test/DoctypeTest.php
index 2d6d0cb..59c583a 100644
--- a/Test/DoctypeTest.php
+++ b/Test/DoctypeTest.php
@@ -10,12 +10,12 @@ class DoctypeTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Renderer */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/doctypes'
],
@@ -27,7 +27,7 @@ public function setUp()
public function testXmlDoctype()
{
- $this->assertEquals('Some link Some Content ', $this->_renderer->render(
+ $this->assertEquals('Some link Some Content ', $this->renderer->render(
'xml'
));
}
@@ -35,7 +35,7 @@ public function testXmlDoctype()
public function testHtmlDoctype()
{
- $this->assertEquals('Some link Some Content ', $this->_renderer->render(
+ $this->assertEquals('Some link Some Content ', $this->renderer->render(
'html'
));
}
@@ -43,7 +43,7 @@ public function testHtmlDoctype()
public function testXhtmlDoctype()
{
- $this->assertEquals('Some link Some Content ', $this->_renderer->render(
+ $this->assertEquals('Some link Some Content ', $this->renderer->render(
'xhtml'
));
}
diff --git a/Test/EscapingTest.php b/Test/EscapingTest.php
index aa5ab84..fe02c1b 100644
--- a/Test/EscapingTest.php
+++ b/Test/EscapingTest.php
@@ -9,12 +9,12 @@ class EscapingTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Renderer */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/escaping'
],
@@ -26,7 +26,7 @@ public function setUp()
public function testEscapedExpressionCompilation()
{
- $this->assertEquals('=htmlentities(isset($someExpression) ? $someExpression : \'\', \ENT_QUOTES, \'UTF-8\')?>', $this->_renderer->compile('= $someExpression'));
+ $this->assertEquals('=htmlentities(isset($someExpression) ? $someExpression : \'\', \ENT_QUOTES, \'UTF-8\')?>', $this->renderer->compile('= $someExpression'));
}
public function testEscapedExpressionRendering()
@@ -34,7 +34,7 @@ public function testEscapedExpressionRendering()
$this->assertEquals(
'<a href="#">' some random text &</a>
',
- $this->_renderer->render('escaped-expression', ['expression' => '\' some random text & '])
+ $this->renderer->render('escaped-expression', ['expression' => '\' some random text & '])
);
}
@@ -43,118 +43,118 @@ public function testUnescapedExpressionCompilation()
$this->assertEquals(
'=isset($someExpression) ? $someExpression : \'\'?>',
- $this->_renderer->compile('!= $someExpression')
+ $this->renderer->compile('!= $someExpression')
);
}
public function testUnescapedExpressionRendering()
{
- $this->assertEquals('\' some random text &
', $this->_renderer->render('unescaped-expression', ['expression' => '\' some random text & ']));
+ $this->assertEquals('\' some random text &
', $this->renderer->render('unescaped-expression', ['expression' => '\' some random text & ']));
}
public function testUncheckedExpressionCompilation()
{
- $this->assertEquals('=htmlentities($someExpression, \ENT_QUOTES, \'UTF-8\')?>', $this->_renderer->compile('?= $someExpression'));
- $this->assertEquals('=htmlentities($someExpression, \ENT_QUOTES, \'UTF-8\')?>
', $this->_renderer->compile("div\n\tp?= \$someExpression"));
+ $this->assertEquals('=htmlentities($someExpression, \ENT_QUOTES, \'UTF-8\')?>', $this->renderer->compile('?= $someExpression'));
+ $this->assertEquals('=htmlentities($someExpression, \ENT_QUOTES, \'UTF-8\')?>
', $this->renderer->compile("div\n\tp?= \$someExpression"));
}
public function testUncheckedUnescapedExpressionCompilation()
{
- $this->assertEquals('=$someExpression?>', $this->_renderer->compile('?!= $someExpression'));
- $this->assertEquals('', $this->_renderer->compile("div\n\tp?!= \$someExpression"));
+ $this->assertEquals('=$someExpression?>', $this->renderer->compile('?!= $someExpression'));
+ $this->assertEquals('', $this->renderer->compile("div\n\tp?!= \$someExpression"));
}
public function testEscapedInterpolationCompilation()
{
- $this->assertEquals('Some =htmlentities(isset($someVar) ? $someVar : \'\', \ENT_QUOTES, \'UTF-8\')?> random text
', $this->_renderer->compile('p Some #{$someVar} random text'));
+ $this->assertEquals('Some =htmlentities(isset($someVar) ? $someVar : \'\', \ENT_QUOTES, \'UTF-8\')?> random text
', $this->renderer->compile('p Some #{$someVar} random text'));
}
public function testEscapedInterpolationRendering()
{
- $this->assertEquals('In this random text i will insert an <a href="#">' some random text &</a>, awesome, isn\'t it?
', $this->_renderer->render('escaped-interpolation', ['expression' => '\' some random text & ']));
+ $this->assertEquals('In this random text i will insert an <a href="#">' some random text &</a>, awesome, isn\'t it?
', $this->renderer->render('escaped-interpolation', ['expression' => '\' some random text & ']));
}
public function testUnescapedInterpolationRendering()
{
- $this->assertEquals('In this random text i will insert an \' some random text & , awesome, isn\'t it?
', $this->_renderer->render('unescaped-interpolation', ['expression' => '\' some random text & ']));
+ $this->assertEquals('In this random text i will insert an \' some random text & , awesome, isn\'t it?
', $this->renderer->render('unescaped-interpolation', ['expression' => '\' some random text & ']));
}
public function testUncheckedInterpolationCompilation()
{
- $this->assertEquals('Some =htmlentities($someVar, \ENT_QUOTES, \'UTF-8\')?> random text
', $this->_renderer->compile('p Some ?#{$someVar} random text'));
+ $this->assertEquals('Some =htmlentities($someVar, \ENT_QUOTES, \'UTF-8\')?> random text
', $this->renderer->compile('p Some ?#{$someVar} random text'));
}
public function testUncheckedUnescapedInterpolationCompilation()
{
- $this->assertEquals('Some =$someVar?> random text
', $this->_renderer->compile('p Some ?!{$someVar} random text'));
+ $this->assertEquals('Some =$someVar?> random text
', $this->renderer->compile('p Some ?!{$someVar} random text'));
}
public function testEscapedAttributeCompilation()
{
- $this->assertEquals('> ', $this->_renderer->compile('a(href=$url)'));
+ $this->assertEquals('> ', $this->renderer->compile('a(href=$url)'));
}
public function testUnescapedAttributeCompilation()
{
- $this->assertEquals('> ', $this->_renderer->compile('a(href!=$url)'));
+ $this->assertEquals('> ', $this->renderer->compile('a(href!=$url)'));
}
public function testUncheckedAttributeCompilation()
{
- $this->assertEquals('> ', $this->_renderer->compile('a(href?=$url)'));
+ $this->assertEquals('> ', $this->renderer->compile('a(href?=$url)'));
}
public function testUncheckedUnescapedCompilation()
{
- $this->assertEquals('> ', $this->_renderer->compile('a(href?!=$url)'));
+ $this->assertEquals('> ', $this->renderer->compile('a(href?!=$url)'));
}
public function testUnescapedText()
{
- $this->assertEquals('Some Text ', $this->_renderer->compile('| Some Text '));
- $this->assertEquals('Some Text
', $this->_renderer->compile('div Some Text '));
- $this->assertEquals('Some Text Some further text
', $this->_renderer->compile("p.\n\tSome Text \n\tSome further text"));
+ $this->assertEquals('Some Text ', $this->renderer->compile('| Some Text '));
+ $this->assertEquals('Some Text
', $this->renderer->compile('div Some Text '));
+ $this->assertEquals('Some Text Some further text
', $this->renderer->compile("p.\n\tSome Text \n\tSome further text"));
}
public function testEscapedText()
{
- $this->assertEquals('=htmlentities(\'Some Text \', \ENT_QUOTES, \'UTF-8\')?>', $this->_renderer->compile('!| Some Text '));
- $this->assertEquals('=htmlentities(\'Some Text \', \ENT_QUOTES, \'UTF-8\')?>
', $this->_renderer->compile('div! Some Text '));
- $this->assertEquals('=htmlentities(\'Some Text \', \ENT_QUOTES, \'UTF-8\')?> =htmlentities(\'Some further text\', \ENT_QUOTES, \'UTF-8\')?>
', $this->_renderer->compile("p!.\n\tSome Text \n\tSome further text"));
+ $this->assertEquals('=htmlentities(\'Some Text \', \ENT_QUOTES, \'UTF-8\')?>', $this->renderer->compile('!| Some Text '));
+ $this->assertEquals('=htmlentities(\'Some Text \', \ENT_QUOTES, \'UTF-8\')?>
', $this->renderer->compile('div! Some Text '));
+ $this->assertEquals('=htmlentities(\'Some Text \', \ENT_QUOTES, \'UTF-8\')?> =htmlentities(\'Some further text\', \ENT_QUOTES, \'UTF-8\')?>
', $this->renderer->compile("p!.\n\tSome Text \n\tSome further text"));
}
public function testInterpolationInEscapedText()
{
- $this->assertEquals('=htmlentities(\'This is some text \'.(isset($var[\'some var\']) ? $var[\'some var\'] : \'\').\' \', \ENT_QUOTES, \'UTF-8\')?>
', $this->_renderer->compile('p! This is some text !{$var[\'some var\']} #[a(href!=\'abc\')]'));
+ $this->assertEquals('=htmlentities(\'This is some text \'.(isset($var[\'some var\']) ? $var[\'some var\'] : \'\').\' \', \ENT_QUOTES, \'UTF-8\')?>
', $this->renderer->compile('p! This is some text !{$var[\'some var\']} #[a(href!=\'abc\')]'));
}
public function testNewLineEscaping()
{
- $this->assertEquals(" ", $this->_renderer->compile('input(value="Line 1\nLine 2")'));
+ $this->assertEquals(" ", $this->renderer->compile('input(value="Line 1\nLine 2")'));
}
public function testTabEscaping()
{
- $this->assertEquals(" ", $this->_renderer->compile('input(value="Line 1\tLine 2")'));
+ $this->assertEquals(" ", $this->renderer->compile('input(value="Line 1\tLine 2")'));
}
public function testCarriageReturnEscaping()
{
- $this->assertEquals(" ", $this->_renderer->compile('input(value="Line 1\rLine 2")'));
+ $this->assertEquals(" ", $this->renderer->compile('input(value="Line 1\rLine 2")'));
}
}
\ No newline at end of file
diff --git a/Test/ExpressionAndCodeTest.php b/Test/ExpressionAndCodeTest.php
index 3b7a087..68a68d6 100644
--- a/Test/ExpressionAndCodeTest.php
+++ b/Test/ExpressionAndCodeTest.php
@@ -8,48 +8,48 @@ class ExpressionAndCodeTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Compiler */
- private $_compiler;
+ private $compiler;
public function setUp()
{
- $this->_compiler = new Compiler();
+ $this->compiler = new Compiler();
}
public function testSimpleExpression()
{
- $this->assertEquals('=htmlentities(isset($someExpression) ? $someExpression : \'\', \ENT_QUOTES, \'UTF-8\')?>', $this->_compiler->compile('= $someExpression'));
+ $this->assertEquals('=htmlentities(isset($someExpression) ? $someExpression : \'\', \ENT_QUOTES, \'UTF-8\')?>', $this->compiler->compile('= $someExpression'));
}
public function testUnescapedExpression()
{
- $this->assertEquals('=isset($someExpression) ? $someExpression : \'\'?>', $this->_compiler->compile('!= $someExpression'));
+ $this->assertEquals('=isset($someExpression) ? $someExpression : \'\'?>', $this->compiler->compile('!= $someExpression'));
}
public function testFunctionExpression()
{
- $this->assertEquals('=htmlentities(someFunctionCall(), \ENT_QUOTES, \'UTF-8\')?>', $this->_compiler->compile('= someFunctionCall()'));
+ $this->assertEquals('=htmlentities(someFunctionCall(), \ENT_QUOTES, \'UTF-8\')?>', $this->compiler->compile('= someFunctionCall()'));
}
public function testUnescapedFunctionExpression()
{
- $this->assertEquals('=someFunctionCall()?>', $this->_compiler->compile('!= someFunctionCall()'));
+ $this->assertEquals('=someFunctionCall()?>', $this->compiler->compile('!= someFunctionCall()'));
}
public function testSimpleCode()
{
- $this->assertEquals('', $this->_compiler->compile('- while($i < 15) doSomething();'));
+ $this->assertEquals('', $this->compiler->compile('- while($i < 15) doSomething();'));
}
public function testCodeBlock()
{
- $this->assertEquals('', $this->_compiler->compile('-
+ $this->assertEquals('', $this->compiler->compile('-
foreach ($post in $posts) {
doSomethingWith($post);
}
@@ -62,7 +62,7 @@ public function testIssue21()
$this->assertEquals(
'=$view->render(\'_search\', [\'model\' => $searchModel])?>',
- $this->_compiler->compile('!=$view->render(\'_search\', [\'model\' => $searchModel])')
+ $this->compiler->compile('!=$view->render(\'_search\', [\'model\' => $searchModel])')
);
}
}
\ No newline at end of file
diff --git a/Test/FilterTest.php b/Test/FilterTest.php
index 014088d..6f797c8 100644
--- a/Test/FilterTest.php
+++ b/Test/FilterTest.php
@@ -8,18 +8,18 @@ class FilterTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Compiler */
- private $_compiler;
+ private $compiler;
public function setUp()
{
- $this->_compiler = new Compiler();
+ $this->compiler = new Compiler();
}
public function testSingleLineJsFilter()
{
- $this->assertEquals('', $this->_compiler->compile(':js some.java.script();'));
+ $this->assertEquals('', $this->compiler->compile(':js some.java.script();'));
}
public function testMultiLineJsFilter()
@@ -33,14 +33,14 @@ public function testMultiLineJsFilter()
$this->assertEquals(
'',
- $this->_compiler->compile($jade)
+ $this->compiler->compile($jade)
);
}
public function testSingleLineCssFilter()
{
- $this->assertEquals('', $this->_compiler->compile(':css some, random {css: code;}'));
+ $this->assertEquals('', $this->compiler->compile(':css some, random {css: code;}'));
}
public function testMultiLineCssFilter()
@@ -57,7 +57,7 @@ public function testMultiLineCssFilter()
$this->assertEquals(
'',
- $this->_compiler->compile($jade)
+ $this->compiler->compile($jade)
);
}
}
\ No newline at end of file
diff --git a/Test/IdTest.php b/Test/IdTest.php
index cbdeb4d..502ba14 100644
--- a/Test/IdTest.php
+++ b/Test/IdTest.php
@@ -8,18 +8,18 @@ class IdTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Compiler */
- private $_compiler;
+ private $compiler;
public function setUp()
{
- $this->_compiler = new Compiler();
+ $this->compiler = new Compiler();
}
public function testId()
{
- $this->assertEquals('Test
', $this->_compiler->compile('#test Test'));
+ $this->assertEquals('Test
', $this->compiler->compile('#test Test'));
}
public function testNestedId()
@@ -30,13 +30,13 @@ public function testNestedId()
#testChild Test
JADE;
- $this->assertEquals('', $this->_compiler->compile($jade));
+ $this->assertEquals('', $this->compiler->compile($jade));
}
public function testTagIdCombination()
{
- $this->assertEquals('Test
', $this->_compiler->compile('p#test Test'));
+ $this->assertEquals('Test
', $this->compiler->compile('p#test Test'));
}
public function testNestedTagIdCombination()
@@ -47,7 +47,7 @@ public function testNestedTagIdCombination()
p#testChild Test
JADE;
- $this->assertEquals('', $this->_compiler->compile($jade));
+ $this->assertEquals('', $this->compiler->compile($jade));
}
public function testComplexTagIdCombination()
@@ -81,6 +81,6 @@ public function testComplexTagIdCombination()
a#testLink9
JADE;
- $this->assertEquals('
', $this->_compiler->compile($jade));
+ $this->assertEquals('
', $this->compiler->compile($jade));
}
}
\ No newline at end of file
diff --git a/Test/ImportTest.php b/Test/ImportTest.php
index 1e46fdb..3b178ae 100644
--- a/Test/ImportTest.php
+++ b/Test/ImportTest.php
@@ -9,12 +9,12 @@ class ImportTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Compiler */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/imports'
],
@@ -26,7 +26,7 @@ public function setUp()
public function testExtends()
{
- $this->assertEquals('Some Template Passed content to extended file!
', $this->_renderer->render(
+ $this->assertEquals('Some Template Passed content to extended file!
', $this->renderer->render(
'extends'
));
}
@@ -34,7 +34,7 @@ public function testExtends()
public function testInclude()
{
- $this->assertEquals('Included! I was included, man!
Included! I was included, man!
', $this->_renderer->render(
+ $this->assertEquals('Included! I was included, man!
Included! I was included, man!
', $this->renderer->render(
'include'
));
}
@@ -42,7 +42,7 @@ public function testInclude()
public function testIncludeFilters()
{
- $this->assertEquals('Hello from PHP!Hello from PHP!', $this->_renderer->render(
+ $this->assertEquals('Hello from PHP!Hello from PHP!', $this->renderer->render(
'include-filters'
));
}
@@ -52,7 +52,7 @@ public function testFileNotFound()
$this->setExpectedException(Compiler\Exception::class);
- $this->_renderer->compile('include non-existent-file');
- $this->_renderer->compile('extends non-existent-file');
+ $this->renderer->compile('include non-existent-file');
+ $this->renderer->compile('extends non-existent-file');
}
}
\ No newline at end of file
diff --git a/Test/InterpolationTest.php b/Test/InterpolationTest.php
index 1e8c564..33d1b9e 100644
--- a/Test/InterpolationTest.php
+++ b/Test/InterpolationTest.php
@@ -9,12 +9,12 @@ class InterpolationTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Renderer */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/interpolation'
],
@@ -29,7 +29,7 @@ public function setUp()
public function testExpressionInterpolation($prefix, $expression, $expected)
{
- $this->assertEquals($expected, $this->_renderer->compile('p Some Text '.$prefix.'{'.$expression.'}'));
+ $this->assertEquals($expected, $this->renderer->compile('p Some Text '.$prefix.'{'.$expression.'}'));
}
public function expressionProvider()
@@ -57,22 +57,22 @@ public function expressionProvider()
public function testJadeInterpolation()
{
- $this->assertEquals('Some Text Some link
', $this->_renderer->compile('p Some Text #[a Some link]'));
- $this->assertEquals('Some Text =htmlentities(\'Some link \', \ENT_QUOTES, \'UTF-8\')?>
', $this->_renderer->compile('p Some Text ![a Some link]'));
+ $this->assertEquals('Some Text Some link
', $this->renderer->compile('p Some Text #[a Some link]'));
+ $this->assertEquals('Some Text =htmlentities(\'Some link \', \ENT_QUOTES, \'UTF-8\')?>
', $this->renderer->compile('p Some Text ![a Some link]'));
}
public function testNestedInterpolation()
{
- $this->assertEquals('A
B
C
D
', $this->_renderer->compile('p A #[p B #[p C #[p D]]]'));
- $this->assertEquals('A =htmlentities(isset($b) ? $b : \'\', \ENT_QUOTES, \'UTF-8\')?>
C =strtoupper($d)?>
', $this->_renderer->compile('p A #{$b} #[p C !{strtoupper($d)}]'));
+ $this->assertEquals('A
B
C
D
', $this->renderer->compile('p A #[p B #[p C #[p D]]]'));
+ $this->assertEquals('A =htmlentities(isset($b) ? $b : \'\', \ENT_QUOTES, \'UTF-8\')?>
C =strtoupper($d)?>
', $this->renderer->compile('p A #{$b} #[p C !{strtoupper($d)}]'));
}
public function testMultipleInterpolation()
{
- $this->assertEquals('Some text =htmlentities(isset($var) ? $var : \'\', \ENT_QUOTES, \'UTF-8\')?>
A
=htmlentities(strtolower($var), \ENT_QUOTES, \'UTF-8\')?> =htmlentities(isset($otherVar) ? $otherVar : \'\', \ENT_QUOTES, \'UTF-8\')?> =isset($otherVar) ? $otherVar : \'\'?>', $this->_renderer->compile("p.\n\tSome text #{\$var} #[p A] #{strtolower(\$var)} #{\$otherVar} !{\$otherVar}"));
- $this->assertEquals('Some text A
B
=htmlentities(isset($var) ? $var : \'\', \ENT_QUOTES, \'UTF-8\')?> E =isset($otherVar) ? $otherVar : \'\'?> ', $this->_renderer->compile("p.\n\tSome text #[a A] #[p B] #{\$var} #[c.d E] !{\$otherVar} #[f]"));
+ $this->assertEquals('Some text =htmlentities(isset($var) ? $var : \'\', \ENT_QUOTES, \'UTF-8\')?>
A
=htmlentities(strtolower($var), \ENT_QUOTES, \'UTF-8\')?> =htmlentities(isset($otherVar) ? $otherVar : \'\', \ENT_QUOTES, \'UTF-8\')?> =isset($otherVar) ? $otherVar : \'\'?>', $this->renderer->compile("p.\n\tSome text #{\$var} #[p A] #{strtolower(\$var)} #{\$otherVar} !{\$otherVar}"));
+ $this->assertEquals('Some text A
B
=htmlentities(isset($var) ? $var : \'\', \ENT_QUOTES, \'UTF-8\')?> E =isset($otherVar) ? $otherVar : \'\'?> ', $this->renderer->compile("p.\n\tSome text #[a A] #[p B] #{\$var} #[c.d E] !{\$otherVar} #[f]"));
}
public function testInvalidInterpolation()
@@ -80,7 +80,7 @@ public function testInvalidInterpolation()
$this->setExpectedException(Compiler\Exception::class);
- $this->_renderer->compile('#{p Some content');
+ $this->renderer->compile('#{p Some content');
}
public function testInvalidJadeInterpolation()
@@ -88,12 +88,18 @@ public function testInvalidJadeInterpolation()
$this->setExpectedException(Compiler\Exception::class);
- $this->_renderer->compile('#[p Some content');
+ $this->renderer->compile('#[p Some content');
}
public function testMailToLink()
{
- $this->assertEquals('', $this->_renderer->compile('.copyright Copyright (c) 2016 #[a(href=\'mailto:tk@talesoft.io\') tk@talesoft.io] Berlin'));
+ $this->assertEquals('', $this->renderer->compile('.copyright Copyright (c) 2016 #[a(href=\'mailto:tk@talesoft.io\') tk@talesoft.io] Berlin'));
+ }
+
+ public function testIeConditionals()
+ {
+
+ $this->assertEquals('', $this->renderer->compile(""));
}
}
\ No newline at end of file
diff --git a/Test/IssueTest.php b/Test/IssueTest.php
index ff6d698..a47f6b9 100644
--- a/Test/IssueTest.php
+++ b/Test/IssueTest.php
@@ -10,12 +10,12 @@ class IssueTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Renderer */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/issues'
],
@@ -27,13 +27,13 @@ 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'));
+ $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()
{
- $this->assertEquals(' ', $this->_renderer->render(
+ $this->assertEquals(' ', $this->renderer->render(
'issue-33'
));
}
@@ -41,7 +41,7 @@ public function testIssue33()
public function testIssue42()
{
- $this->assertEquals('Some TextSome further text Some TextSome further text ', $this->_renderer->render(
+ $this->assertEquals('Some TextSome further text Some TextSome further text ', $this->renderer->render(
'issue-42'
));
}
@@ -49,15 +49,15 @@ public function testIssue42()
public function testIssue48()
{
- $this->assertEquals('Hello ', $this->_renderer->render(
+ $this->assertEquals('Hello ', $this->renderer->render(
'issue-48/1'
));
- $this->assertEquals(' Submit ', $this->_renderer->render(
+ $this->assertEquals(' Submit ', $this->renderer->render(
'issue-48/views/view.ctp'
));
- $this->assertEquals('
', $this->_renderer->render(
+ $this->assertEquals('
', $this->renderer->render(
'issue-48/escaping',
['clipId' => 1]
));
@@ -88,8 +88,8 @@ public function testIssue44()
$this->assertEquals('', $renderer->compile($jade));
$this->assertEquals(' =$view->Html->charset()?> ', $renderer->compileFile('issue-44'));
- $this->assertEquals('=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> =$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> menu ', $this->_renderer->compileFile('issue-44/for_members.ctp.1'));
- $this->assertEquals('=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> =$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> menu ', $this->_renderer->compileFile('issue-44/for_members.ctp.2'));
+ $this->assertEquals('=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> =$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> menu ', $this->renderer->compileFile('issue-44/for_members.ctp.1'));
+ $this->assertEquals('=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> =$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> menu ', $this->renderer->compileFile('issue-44/for_members.ctp.2'));
$renderer = new Renderer([
@@ -107,19 +107,25 @@ public function testIssue44()
$this->assertEquals('', $renderer->compile($jade));
$this->assertEquals(' =$view->Html->charset()?> ', $renderer->compileFile('issue-44'));
- $this->assertEquals('=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> =$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> menu ', $this->_renderer->compileFile('issue-44/for_members.ctp.1'));
- $this->assertEquals('=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> =$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> menu ', $this->_renderer->compileFile('issue-44/for_members.ctp.2'));
+ $this->assertEquals('=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> =$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> menu ', $this->renderer->compileFile('issue-44/for_members.ctp.1'));
+ $this->assertEquals('=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> =$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?> =$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?> menu ', $this->renderer->compileFile('issue-44/for_members.ctp.2'));
}
public function testIssue55()
{
- $this->assertEquals('Sign In / =$view->Html->link(\'Sign Up\', [\'action\' => \'add\'])?>
', $this->_renderer->compile('.col.s6.right-align #[strong Sign In] / !{$view->Html->link(\'Sign Up\', [\'action\' => \'add\'])}'));
+ $this->assertEquals('Sign In / =$view->Html->link(\'Sign Up\', [\'action\' => \'add\'])?>
', $this->renderer->compile('.col.s6.right-align #[strong Sign In] / !{$view->Html->link(\'Sign Up\', [\'action\' => \'add\'])}'));
}
public function testIssue57()
{
- $this->assertEquals('=htmlentities(\' =htmlentities(\'$foo = \'hey\';\', \ENT_QUOTES, \'UTF-8\')?>
', $this->_renderer->compile("pre: code!.\n\tassertEquals('=htmlentities(\' =htmlentities(\'$foo = \'hey\';\', \ENT_QUOTES, \'UTF-8\')?>
', $this->renderer->compile("pre: code!.\n\tassertEquals('
', $this->renderer->compile('.blogentry(itemscope itemtype="http://schema.org/BlogPosting")'));
}
}
\ No newline at end of file
diff --git a/Test/LoopTest.php b/Test/LoopTest.php
index 69aab4b..95a60a4 100644
--- a/Test/LoopTest.php
+++ b/Test/LoopTest.php
@@ -9,12 +9,12 @@ class LoopTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Renderer */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/loops'
],
@@ -29,7 +29,7 @@ public function setUp()
public function testEach($array, $expected)
{
- $this->assertEquals($expected, $this->_renderer->render('each', ['array' => $array]));
+ $this->assertEquals($expected, $this->renderer->render('each', ['array' => $array]));
}
public function arrayValueProvider()
@@ -45,12 +45,12 @@ public function arrayValueProvider()
public function testWhile()
{
- $this->assertEquals('1 My $i is 0!
1 My $i is 1!
1 My $i is 2!
1 My $i is 3!
1 My $i is 4!
1 My $i is 5!
1 My $i is 6!
1 My $i is 7!
1 My $i is 8!
1 My $i is 9!
1 My $i is 10!
1 My $i is 11!
1 My $i is 12!
1 My $i is 13!
1 My $i is 14!
1 My $i is 15!
1 My $i is 16!
1 My $i is 17!
1 My $i is 18!
1 My $i is 19!
1 My $i is 20!
1 My $i is 21!
1 My $i is 22!
1 My $i is 23!
1 My $i is 24!
2 My $i is 0
2 My $i is 1
2 My $i is 2
2 My $i is 3
2 My $i is 4
2 My $i is 5
2 My $i is 6
2 My $i is 7
2 My $i is 8
2 My $i is 9
2 My $i is 10
2 My $i is 11
2 My $i is 12
2 My $i is 13
2 My $i is 14
2 My $i is 15
2 My $i is 16
2 My $i is 17
2 My $i is 18
2 My $i is 19
2 My $i is 20
2 My $i is 21
2 My $i is 22
2 My $i is 23
2 My $i is 24
', $this->_renderer->render('while'));
+ $this->assertEquals('1 My $i is 0!
1 My $i is 1!
1 My $i is 2!
1 My $i is 3!
1 My $i is 4!
1 My $i is 5!
1 My $i is 6!
1 My $i is 7!
1 My $i is 8!
1 My $i is 9!
1 My $i is 10!
1 My $i is 11!
1 My $i is 12!
1 My $i is 13!
1 My $i is 14!
1 My $i is 15!
1 My $i is 16!
1 My $i is 17!
1 My $i is 18!
1 My $i is 19!
1 My $i is 20!
1 My $i is 21!
1 My $i is 22!
1 My $i is 23!
1 My $i is 24!
2 My $i is 0
2 My $i is 1
2 My $i is 2
2 My $i is 3
2 My $i is 4
2 My $i is 5
2 My $i is 6
2 My $i is 7
2 My $i is 8
2 My $i is 9
2 My $i is 10
2 My $i is 11
2 My $i is 12
2 My $i is 13
2 My $i is 14
2 My $i is 15
2 My $i is 16
2 My $i is 17
2 My $i is 18
2 My $i is 19
2 My $i is 20
2 My $i is 21
2 My $i is 22
2 My $i is 23
2 My $i is 24
', $this->renderer->render('while'));
}
public function testFor()
{
- $this->assertEquals('1 Character at 0 is a
1 Character at 1 is b
1 Character at 2 is c
1 Character at 3 is d
1 Character at 4 is e
1 Character at 5 is f
1 Character at 6 is g
1 Character at 7 is h
1 Character at 8 is i
1 Character at 9 is j
1 Character at 10 is k
1 Character at 11 is l
1 Character at 12 is m
1 Character at 13 is n
1 Character at 14 is o
1 Character at 15 is p
1 Character at 16 is q
1 Character at 17 is r
1 Character at 18 is s
1 Character at 19 is t
1 Character at 20 is u
1 Character at 21 is v
1 Character at 22 is w
1 Character at 23 is x
1 Character at 24 is y
1 Character at 25 is z
', $this->_renderer->render('for'));
+ $this->assertEquals('1 Character at 0 is a
1 Character at 1 is b
1 Character at 2 is c
1 Character at 3 is d
1 Character at 4 is e
1 Character at 5 is f
1 Character at 6 is g
1 Character at 7 is h
1 Character at 8 is i
1 Character at 9 is j
1 Character at 10 is k
1 Character at 11 is l
1 Character at 12 is m
1 Character at 13 is n
1 Character at 14 is o
1 Character at 15 is p
1 Character at 16 is q
1 Character at 17 is r
1 Character at 18 is s
1 Character at 19 is t
1 Character at 20 is u
1 Character at 21 is v
1 Character at 22 is w
1 Character at 23 is x
1 Character at 24 is y
1 Character at 25 is z
', $this->renderer->render('for'));
}
}
\ No newline at end of file
diff --git a/Test/MixinTest.php b/Test/MixinTest.php
index 9101e99..06ff738 100644
--- a/Test/MixinTest.php
+++ b/Test/MixinTest.php
@@ -8,12 +8,12 @@ class MixinTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Renderer */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'cachePath' => __DIR__.'/cache/mixins',
'pretty' => false,
'paths' => [__DIR__.'/views/mixins']
@@ -23,7 +23,7 @@ public function setUp()
public function testDefinitionAndCall()
{
- $this->assertEquals('Default Label Default Label Label 1 Label 2 ', $this->_renderer->render(
+ $this->assertEquals('Default Label Default Label Label 1 Label 2 ', $this->renderer->render(
'definition-and-call', [
'passedLabel' => 'Label 2'
]));
@@ -33,7 +33,7 @@ public function testCompileCalledOnly()
{
//TODO: I think this one doesnt make too much sense, does it?
- $this->assertEquals('This mixin was called
This mixin was called as well
', $this->_renderer->render(
+ $this->assertEquals('This mixin was called
This mixin was called as well
', $this->renderer->render(
'compile-called-only'
));
}
@@ -41,7 +41,7 @@ public function testCompileCalledOnly()
public function testBlock()
{
- $this->assertEquals('Article 1 Block Content 1 Awesome, isn\'t it?
Article 2 Block Content 2 And another block content
', $this->_renderer->render(
+ $this->assertEquals('Article 1 Block Content 1 Awesome, isn\'t it?
Article 2 Block Content 2 And another block content
', $this->renderer->render(
'block'
));
}
@@ -49,7 +49,7 @@ public function testBlock()
public function testArguments()
{
- $this->assertEquals('Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! ', $this->_renderer->render(
+ $this->assertEquals('Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! Some Spacer Content! ', $this->renderer->render(
'arguments'
));
}
@@ -57,7 +57,7 @@ public function testArguments()
public function testIdAndClassForwarding()
{
- $this->assertEquals('My Button Label ', $this->_renderer->render(
+ $this->assertEquals('My Button Label ', $this->renderer->render(
'id-and-class-forwarding'
));
}
@@ -65,7 +65,7 @@ public function testIdAndClassForwarding()
public function testVariadic()
{
- $this->assertEquals('Test 1 Test 2 ', $this->_renderer->render('variadic', ['items' => [
+ $this->assertEquals('Test 1 Test 2 ', $this->renderer->render('variadic', ['items' => [
['name' => 'Item 1', 'id' => 51],
['name' => 'Item 2', 'id' => 52],
['name' => 'Item 3', 'id' => 53],
diff --git a/Test/PrettyTest.php b/Test/PrettyTest.php
index 522dee3..adc7c81 100644
--- a/Test/PrettyTest.php
+++ b/Test/PrettyTest.php
@@ -10,12 +10,12 @@ class PrettyTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Renderer */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/pretty',
],
@@ -51,7 +51,7 @@ public function testBasic()
PHTML;
- $this->assertEquals(str_replace("\r", '', $phtml), $this->_renderer->compileFile(
+ $this->assertEquals(str_replace("\r", '', $phtml), $this->renderer->compileFile(
'basic'
));
}
@@ -81,7 +81,7 @@ public function testSingle()
PHTML;
- $this->assertEquals(str_replace("\r", '', $phtml), $this->_renderer->compileFile(
+ $this->assertEquals(str_replace("\r", '', $phtml), $this->renderer->compileFile(
'single'
));
}
diff --git a/Test/StandAloneTest.php b/Test/StandAloneTest.php
index f24090a..8aac49b 100644
--- a/Test/StandAloneTest.php
+++ b/Test/StandAloneTest.php
@@ -9,12 +9,12 @@ class StandAloneTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Renderer */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/stand-alone',
],
@@ -27,6 +27,6 @@ public function setUp()
public function testStandAloneCompilation()
{
- $this->assertEquals('Test!
', $this->_renderer->render('basic', ['classes' => ['e', 'f']]));
+ $this->assertEquals('Test!
', $this->renderer->render('basic', ['classes' => ['e', 'f']]));
}
}
\ No newline at end of file
diff --git a/Test/TagTest.php b/Test/TagTest.php
index 86f2db6..740251f 100644
--- a/Test/TagTest.php
+++ b/Test/TagTest.php
@@ -8,18 +8,18 @@ class TagTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Compiler */
- private $_compiler;
+ private $compiler;
public function setUp()
{
- $this->_compiler = new Compiler();
+ $this->compiler = new Compiler();
}
public function testTag()
{
- $this->assertEquals('Test
', $this->_compiler->compile('p Test'));
+ $this->assertEquals('Test
', $this->compiler->compile('p Test'));
}
public function testTagChars()
@@ -27,7 +27,7 @@ public function testTagChars()
$this->assertEquals(
'Test ',
- $this->_compiler->compile('abcdefghijklmnopqrstuvwxyz-_ABCDEFGHIJKLMNOPQRSTUVWXYZ Test')
+ $this->compiler->compile('abcdefghijklmnopqrstuvwxyz-_ABCDEFGHIJKLMNOPQRSTUVWXYZ Test')
);
}
@@ -36,12 +36,12 @@ public function testNamespacedTag()
$this->assertEquals(
'Test ',
- $this->_compiler->compile('a:b Test')
+ $this->compiler->compile('a:b Test')
);
$this->assertEquals(
'Test ',
- $this->_compiler->compile('a-b:c-d Test')
+ $this->compiler->compile('a-b:c-d Test')
);
}
@@ -53,7 +53,7 @@ public function testNestedTag()
a Test
JADE;
- $this->assertEquals('Test
', $this->_compiler->compile($jade));
+ $this->assertEquals('Test
', $this->compiler->compile($jade));
}
public function testTabTags()
@@ -72,7 +72,7 @@ public function testTabTags()
\tscript
JADE;
- $this->assertEquals(' ', $this->_compiler->compile($jade));
+ $this->assertEquals(' ', $this->compiler->compile($jade));
}
public function testComplexNestedTag()
@@ -106,6 +106,6 @@ public function testComplexNestedTag()
a
JADE;
- $this->assertEquals('', $this->_compiler->compile($jade));
+ $this->assertEquals('', $this->compiler->compile($jade));
}
}
\ No newline at end of file
diff --git a/Test/VariableTest.php b/Test/VariableTest.php
index a0e6ccd..8b46372 100644
--- a/Test/VariableTest.php
+++ b/Test/VariableTest.php
@@ -9,12 +9,12 @@ class VariableTest extends \PHPUnit_Framework_TestCase
{
/** @var \Tale\Jade\Renderer */
- private $_renderer;
+ private $renderer;
public function setUp()
{
- $this->_renderer = new Renderer([
+ $this->renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/variables'
],
@@ -26,7 +26,7 @@ public function setUp()
public function testAssignment()
{
- $this->assertEquals('Hello World!
nowrap212
', $this->_renderer->render('assignment', [
+ $this->assertEquals('Hello World!
nowrap212
', $this->renderer->render('assignment', [
'existing' => ['style' => ['width' => '100%'], 'class' => 'test']
]));
}
diff --git a/Test/views/doctypes/html.jade b/Test/views/doctypes/html.jade
index 67b3d4a..ec69de8 100644
--- a/Test/views/doctypes/html.jade
+++ b/Test/views/doctypes/html.jade
@@ -7,7 +7,7 @@ img
link
area
-//These should repeat
+//These shouldn't repeat
a(disabled, selected, checked) Some link
//this should self-close
diff --git a/composer.json b/composer.json
index 61135bd..a176717 100644
--- a/composer.json
+++ b/composer.json
@@ -25,10 +25,7 @@
"minimum-stability": "stable",
"require": {
"php": ">=5.5.0",
- "talesoft/tale-config": "0.1"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.0"
+ "talesoft/tale-config": "0.2"
},
"autoload": {
"psr-4": {
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..118d0d8
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,117 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "This file is @generated automatically"
+ ],
+ "hash": "e79046d5a84193ea57431be23b8aba39",
+ "content-hash": "d4e9d060cca8ed44cefc8c5ba5f1a217",
+ "packages": [
+ {
+ "name": "talesoft/tale-config",
+ "version": "0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Talesoft/tale-config.git",
+ "reference": "1a9304e99753fa74c4f43722b52388df8015eb03"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Talesoft/tale-config/zipball/1a9304e99753fa74c4f43722b52388df8015eb03",
+ "reference": "1a9304e99753fa74c4f43722b52388df8015eb03",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5.0",
+ "talesoft/tale-factory": "~0.1"
+ },
+ "suggest": {
+ "symfony/yaml": "for YAML-configuration",
+ "talesoft/tale-dom": "for XML-configuration"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Tale\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Torben Koehn",
+ "email": "tk@talesoft.io"
+ },
+ {
+ "name": "Talesoft",
+ "email": "info@talesoft.io",
+ "homepage": "http://talesoft.io"
+ }
+ ],
+ "description": "Lightweight configuration interfaces and utilities",
+ "homepage": "http://docs.talesoft.io/tale-framework/tale/config",
+ "keywords": [
+ "config",
+ "options"
+ ],
+ "time": "2016-03-01 22:39:06"
+ },
+ {
+ "name": "talesoft/tale-factory",
+ "version": "0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Talesoft/tale-factory.git",
+ "reference": "2ff9f746d1636048b9c0cc7c9c24d17c82c3a7ac"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Talesoft/tale-factory/zipball/2ff9f746d1636048b9c0cc7c9c24d17c82c3a7ac",
+ "reference": "2ff9f746d1636048b9c0cc7c9c24d17c82c3a7ac",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Tale\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Torben Koehn",
+ "email": "tk@talesoft.io"
+ },
+ {
+ "name": "Talesoft",
+ "email": "info@talesoft.io",
+ "homepage": "http://talesoft.io"
+ }
+ ],
+ "description": "A small and lightweight implementation of the factory pattern",
+ "homepage": "http://docs.talesoft.io/tale-framework/tale/factory",
+ "keywords": [
+ "factory"
+ ],
+ "time": "2016-03-01 19:06:00"
+ }
+ ],
+ "packages-dev": [],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": {
+ "php": ">=5.5.0"
+ },
+ "platform-dev": []
+}
diff --git a/functions.php b/functions.php
index 15c1296..c6f4ca3 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.4.0
+ * @version 1.4.2
* @link http://jade.talesoft.io/docs/files/functions.html
* @since File available since Tag 1.0.1
*/
diff --git a/tasks b/tasks
index 7905a5e..d7fe807 100644
--- a/tasks
+++ b/tasks
@@ -10,7 +10,7 @@ $ignore = [
'./.git'
];
-$newVersion = '1.4.0';
+$newVersion = '1.4.2';
if (!$newVersion) {