The result can then be evaluated, the best method is
a simple PHP include
Use ->render() to get this done for you
Before evaluating you should set a $__args variables
that will be passed through mixins.
It like a global scope.
If you give it a path, the directory of that path will be used
for relative includes.
public function testIssue18() { $jade = <<<JADE - if (\$something): p Do something - endif; - if (\$something && \$somethingElse) { p Do some random stuff - } - if (\$something && \$somethingElse) { echo "No jade handling here"; } \$array = ["a","b" "c", "d", "e", "f", "g", "h"]; p and it goes on normally... JADE; $this->assertEquals('<?php if ($something):?><p>Do something</p><?php endif;?><?php if ($something && $somethingElse) {?><p>Do some random stuff</p><?php }?><?php if ($something && $somethingElse) {echo "No jade handling here"; } $array = ["a","b""c", "d","e", "f", "g", "h"];?><p>and it goes on normally...</p>', $this->_renderer->compile($jade)); }
public function testCarriageReturnEscaping() { $this->assertEquals("<input value=\"Line 1\rLine 2\">", $this->_renderer->compile('input(value="Line 1\\rLine 2")')); }
public function testIssue66() { $this->assertEquals('<div class="blogentry" itemscope itemtype="http://schema.org/BlogPosting"></div>', $this->renderer->compile('.blogentry(itemscope itemtype="http://schema.org/BlogPosting")')); }
public function testTagInterpolation() { $this->assertEquals('<?php $tagName = \'abcdefghi\'?><<?=htmlentities(isset($tagName) ? $tagName : \'\', \\ENT_QUOTES, \'UTF-8\')?> class="some-class">Some Content</<?=htmlentities(isset($tagName) ? $tagName : \'\', \\ENT_QUOTES, \'UTF-8\')?>>', $this->renderer->compile("\$tagName='abcdefghi'\n#{\$tagName}.some-class Some Content")); $this->assertEquals('<?php $tagName = \'def\'?><abc<?=htmlentities(isset($tagName) ? $tagName : \'\', \\ENT_QUOTES, \'UTF-8\')?>ghi class="some-class">Some Content</abc<?=htmlentities(isset($tagName) ? $tagName : \'\', \\ENT_QUOTES, \'UTF-8\')?>ghi>', $this->renderer->compile("\$tagName='def'\nabc#{\$tagName}ghi.some-class Some Content")); $this->assertEquals('<?php $t1 = \'abc\'?><?php $t2 = \'def\'?><abc<?=htmlentities(isset($t1) ? $t1 : \'\', \\ENT_QUOTES, \'UTF-8\')?>ghi-<?=htmlentities(isset($t2) ? $t2 : \'\', \\ENT_QUOTES, \'UTF-8\')?> class="some-class">Some Content</abc<?=htmlentities(isset($t1) ? $t1 : \'\', \\ENT_QUOTES, \'UTF-8\')?>ghi-<?=htmlentities(isset($t2) ? $t2 : \'\', \\ENT_QUOTES, \'UTF-8\')?>>', $this->renderer->compile("\$t1='abc'\n\$t2='def'\nabc#{\$t1}ghi-#{\$t2}.some-class Some Content")); }
public function testExpectedButNotGivenValue() { $this->assertEquals('<!DOCTYPE html><a href></a>', $this->renderer->compile("doctype html\na(href=)")); $this->assertEquals('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><a href=""></a>', $this->renderer->compile("doctype default\na(href=)")); $this->assertEquals('<?xml version="1.0" encoding="utf-8"?><a href="" />', $this->renderer->compile("doctype xml\na(href=)")); }
public function testIssue57() { $this->assertEquals('<pre><code><?=htmlentities(\'<?php\', \\ENT_QUOTES, \'UTF-8\')?> <?=htmlentities(\'$foo = \'hey\';\', \\ENT_QUOTES, \'UTF-8\')?></code></pre>', $this->_renderer->compile("pre: code!.\n\t<?php\n\t\$foo = 'hey';")); }
public function testInvalidJadeInterpolation() { $this->setExpectedException(Compiler\Exception::class); $this->_renderer->compile('#[p Some content'); }
public function testMailToLink() { $this->assertEquals('<div class="copyright">Copyright (c) 2016 <a href="mailto:tk@talesoft.io">tk@talesoft.io</a> Berlin</div>', $this->_renderer->compile('.copyright Copyright (c) 2016 #[a(href=\'mailto:tk@talesoft.io\') tk@talesoft.io] Berlin')); }
public function testExpectedButNotGivenValue() { $this->assertEquals('<a href=""></a>', $this->_renderer->compile('a(href=)')); }
public function testIeConditionals() { $this->assertEquals('<!--[if IE8]><script src="ie8.js"></script> <![endif]-->', $this->renderer->compile("<!--[if IE8]>\nscript(src='ie8.js')\n<![endif]-->")); }
public function testIssue105() { $this->assertEquals('<script id="stylmock" data-items="globals" data-project="wdg_inv_2016_olya" data-save_path="c:\\\\Apache24\\\\htdocs\\\\romero\\\\wdg\\\\wdg_html\\\\wp-content\\\\themes\\\\invite2016\\\\styles.css"></script>', $this->renderer->compile("script#stylmock(data-items='globals' data-project='wdg_inv_2016_olya' data-save_path='c:\\\\Apache24\\\\htdocs\\\\romero\\\\wdg\\\\wdg_html\\\\wp-content\\\\themes\\\\invite2016\\\\styles.css')")); }
public function testIssue55() { $this->assertEquals('<div class="col s6 right-align"><strong>Sign In</strong> / <?=$view->Html->link(\'Sign Up\', [\'action\' => \'add\'])?></div>', $this->_renderer->compile('.col.s6.right-align #[strong Sign In] / !{$view->Html->link(\'Sign Up\', [\'action\' => \'add\'])}')); }