Skip to content

Commit

Permalink
Merge pull request #50 from Talesoft/dev-master
Browse files Browse the repository at this point in the history
Minor bugfixes, documentation
  • Loading branch information
TorbenKoehn committed Jan 16, 2016
2 parents 77dc417 + 0046e6a commit 2779857
Show file tree
Hide file tree
Showing 22 changed files with 236 additions and 34 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@

language: php

git:
depth: 5

php:
- 5.5
- 5.6
- 7.0
- hhvm

before_script:
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi;

install:
- composer self-update
- composer install
- composer install --no-dev
4 changes: 2 additions & 2 deletions Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Compiler.html
* @since File available since Release 1.0
*/
Expand Down Expand Up @@ -91,7 +91,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Compiler.html
* @since File available since Release 1.0
*/
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Compiler.Exception.html
* @since File available since Release 1.0
*/
Expand All @@ -35,7 +35,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Compiler.Exception.html
* @since File available since Release 1.0
*/
Expand Down
4 changes: 2 additions & 2 deletions Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Filter.html
* @since File available since Release 1.0
*/
Expand Down Expand Up @@ -53,7 +53,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Filter.html
* @since File available since Release 1.0
*/
Expand Down
12 changes: 8 additions & 4 deletions Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Lexer.html
* @since File available since Release 1.0
*/

namespace Tale\Jade;

use RuntimeException;
use Tale\Jade\Lexer\Exception;

/**
Expand Down Expand Up @@ -60,7 +61,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Lexer.html
* @since File available since Release 1.0
*/
Expand Down Expand Up @@ -208,14 +209,14 @@ public function __construct(array $options = null)

//Validate options
if (!in_array($this->_options['indentStyle'], [null, self::INDENT_TAB, self::INDENT_SPACE]))
throw new \Exception(
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)
)
throw new \Exception(
throw new RuntimeException(
"indentWidth needs to be a integer above 0"
);
}
Expand Down Expand Up @@ -875,6 +876,8 @@ protected function scanIndent()
$mixed = false;
} else {

var_dump($this->_indentStyle, $this->_indentWidth, $spaces, $tabs, $mixed);

$this->throwException(
"Mixed indentation style encountered. "
."Dont mix tabs and spaces. Stick to one of both."
Expand Down Expand Up @@ -1715,6 +1718,7 @@ protected function scanAttributes()

$token['escaped'] = false;
$this->consume();
$char = $this->peek();
}

if (!$token['name'] || $char === '=') {
Expand Down
4 changes: 2 additions & 2 deletions Lexer/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Lexer.Exception.html
* @since File available since Release 1.0
*/
Expand All @@ -34,7 +34,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Lexer.Exception.html
* @since File available since Release 1.0
*/
Expand Down
6 changes: 3 additions & 3 deletions Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Parser.html
* @since File available since Release 1.0
*/
Expand Down Expand Up @@ -57,7 +57,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Parser.html
* @since File available since Release 1.0
*/
Expand Down Expand Up @@ -172,7 +172,7 @@ class Parser
public function __construct(array $options = null, Lexer $lexer = null)
{

$this->defineOptions(['lexerOptions' => $options], $options);
$this->defineOptions(['lexerOptions' => []], $options);

$this->_lexer = $lexer ? $lexer : new Lexer($this->_options['lexerOptions']);
}
Expand Down
4 changes: 2 additions & 2 deletions Parser/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Parser.Exception.html
* @since File available since Release 1.0
*/
Expand All @@ -34,7 +34,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Parser.Exception.html
* @since File available since Release 1.0
*/
Expand Down
4 changes: 2 additions & 2 deletions Parser/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Parser.Node.html
* @since File available since Release 1.0
*/
Expand All @@ -40,7 +40,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Parser.Node.html
* @since File available since Release 1.0
*/
Expand Down
8 changes: 4 additions & 4 deletions Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Renderer.html
* @since File available since Release 1.0
*/
Expand Down Expand Up @@ -51,7 +51,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.html
* @since File available since Release 1.0
*/
Expand Down Expand Up @@ -144,8 +144,8 @@ public function __construct(
$this->forwardOption('filterMap', 'compilerOptions');

$this->_lexer = $lexer ? $lexer : new Lexer($this->_options['lexerOptions']);
$this->_parser = $parser ? $parser : new Parser($this->_options['parserOptions'], $lexer);
$this->_compiler = $compiler ? $compiler : new Compiler($this->_options['compilerOptions'], $parser);
$this->_parser = $parser ? $parser : new Parser($this->_options['parserOptions'], $this->_lexer);
$this->_compiler = $compiler ? $compiler : new Compiler($this->_options['compilerOptions'], $this->_parser);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Renderer/Adapter/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Renderer.Adapter.File.html
* @since File available since Release 1.0
*/
Expand Down Expand Up @@ -59,7 +59,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.Adapter.File.html
* @since File available since Release 1.0
*/
Expand Down
4 changes: 2 additions & 2 deletions Renderer/Adapter/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Renderer.Adapter.Stream.html
* @since File available since Release 1.0
*/
Expand Down Expand Up @@ -70,7 +70,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.Adapter.Stream.html
* @since File available since Release 1.0
*/
Expand Down
4 changes: 2 additions & 2 deletions Renderer/Adapter/Stream/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Renderer.Adapter.Stream.Wrapper.html
* @since File available since Release 1.0
*/
Expand All @@ -42,7 +42,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.Adapter.Stream.Wrapper.html
* @since File available since Release 1.0
*/
Expand Down
4 changes: 2 additions & 2 deletions Renderer/AdapterBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/files/Renderer.AdapterBase.html
* @since File available since Release 1.0
*/
Expand All @@ -41,7 +41,7 @@
* @author Talesoft <[email protected]>
* @copyright Copyright (c) 2015 Talesoft (http://talesoft.io)
* @license http://licenses.talesoft.io/2015/MIT.txt MIT License
* @version 1.3.5
* @version 1.3.6
* @link http://jade.talesoft.io/docs/classes/Tale.Jade.Renderer.AdapterBase.html
* @since File available since Release 1.0
*/
Expand Down
20 changes: 20 additions & 0 deletions Test/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ public function testRendererForwardsOptionsToCompiler($option, $value)
$this->assertEquals($value, $renderer->getCompiler()->getOption($option));
}

/**
* @dataProvider lexerOptionProvider
*/
public function testRendererForwardsOptionsToLexer($option, $value)
{

$renderer = new Renderer(['lexerOptions' => [$option => $value]]);

$this->assertEquals($value, $renderer->getLexer()->getOption($option));
}

public function compilerOptionProvider()
{

Expand All @@ -43,4 +54,13 @@ public function compilerOptionProvider()
['mode', Compiler::MODE_XHTML]
];
}

public function lexerOptionProvider()
{

return [
['indentWidth', 8],
['indentStyle', "\t"]
];
}
}
34 changes: 34 additions & 0 deletions Test/IssueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,39 @@ public function testIssue48()
$this->assertEquals(' <button>Submit</button>', $this->_renderer->render(
'issue-48/views/view.ctp'
));

$this->assertEquals('<div id="clip_1"></div>', $this->_renderer->render(
'issue-48/escaping',
['clipId' => 1]
));
}

public function testIssue44()
{

$jade = <<<JADE
-
\t\t/**
\t\t* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
\t\t* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
\t\t*/
doctype html
JADE;

$renderer = new Renderer([
'adapterOptions' => [
'path' => __DIR__.'/cache/issues'
],
'lexerOptions' => [
'indentWidth' => 2,
'indentStyle' => ' '
],
'pretty' => false,
'paths' => [__DIR__.'/views/issues']
]);

$this->assertEquals('<?php /** * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) */?><!DOCTYPE html>', $renderer->compile($jade));
$this->assertEquals('<?php /** * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) */?><!DOCTYPE html>', $renderer->compileFile('issue-44'));
}
}
Loading

0 comments on commit 2779857

Please sign in to comment.