Commit 553f3678 by Jordi Boggiano

Fix issue with long blocks parsing

parent 0f9e323d
......@@ -1592,7 +1592,7 @@ class Dwoo_Compiler implements Dwoo_ICompiler
if (is_array($parsingParams) || $curBlock != 'root') {
$paramspos = strpos($cmdstr, '(');
$paramsep = ')';
} elseif(preg_match_all('#[a-z0-9_]+(\s*\(|\s+[^(])#i', $cmdstr, $match, PREG_OFFSET_CAPTURE)) {
} elseif(preg_match_all('#^\s*[\\\\:a-z0-9_]+(\s*\(|\s+[^(])#i', $cmdstr, $match, PREG_OFFSET_CAPTURE)) {
$paramspos = $match[1][0][1];
$paramsep = substr($match[1][0][0], -1) === '(' ? ')':'';
if($paramsep === ')') {
......
......@@ -112,7 +112,7 @@ class Dwoo_Plugin_extends extends Dwoo_Plugin implements Dwoo_ICompilable
$newSource = $parent['source'];
}
$newSource = preg_replace_callback(self::$regex, array('Dwoo_Plugin_extends', 'replaceBlock'), $newSource);
$newSource = $l.'do extendsCheck("'.$parent['resource'].':'.$parent['identifier'].'")'.$r.$newSource;
$newSource = $l.'do extendsCheck('.var_export($parent['resource'].':'.$parent['identifier'], true).')'.$r.$newSource;
if (self::$lastReplacement) {
break;
......
......@@ -147,6 +147,14 @@ toplevelContent2
baz"));
}
public function testExtendsHugeBlock()
{
$tpl = new Dwoo_Template_File(dirname(__FILE__).DIRECTORY_SEPARATOR.'resources/extends_huge/home.html');
$tpl->forceCompilation();
$this->assertThat($this->dwoo->get($tpl, array(), $this->compiler), new DwooConstraintStringEquals("<html>".str_repeat('A', 40000).str_repeat('a', 40000)."</html>"));
}
public function testNonExtendedBlocksFromParent()
{
$tpl = new Dwoo_Template_File(dirname(__FILE__).DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'toplevel.html');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment