Update Compiler for new Parser output.
This commit is contained in:
@@ -373,13 +373,11 @@ class Mustache_Compiler
|
|||||||
*/
|
*/
|
||||||
private function text($text, $level)
|
private function text($text, $level)
|
||||||
{
|
{
|
||||||
if ($text === "\n") {
|
$indentNextLine = (substr($text, -1) === "\n");
|
||||||
$this->indentNextLine = true;
|
$code = sprintf($this->prepare(self::TEXT, $level), $this->flushIndent(), var_export($text, true));
|
||||||
|
$this->indentNextLine = $indentNextLine;
|
||||||
|
|
||||||
return $this->prepare(self::LINE, $level);
|
return $code;
|
||||||
} else {
|
|
||||||
return sprintf($this->prepare(self::TEXT, $level), $this->flushIndent(), var_export($text, true));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -467,12 +465,12 @@ class Mustache_Compiler
|
|||||||
*/
|
*/
|
||||||
private function flushIndent()
|
private function flushIndent()
|
||||||
{
|
{
|
||||||
if ($this->indentNextLine) {
|
if (!$this->indentNextLine) {
|
||||||
$this->indentNextLine = false;
|
|
||||||
|
|
||||||
return self::LINE_INDENT;
|
|
||||||
} else {
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->indentNextLine = false;
|
||||||
|
|
||||||
|
return self::LINE_INDENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
|
|||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
array(
|
array(
|
||||||
$this->createTextToken('foo'),
|
$this->createTextToken("foo\n"),
|
||||||
$this->createTextToken("\n"),
|
|
||||||
array(
|
array(
|
||||||
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED,
|
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED,
|
||||||
Mustache_Tokenizer::NAME => 'name',
|
Mustache_Tokenizer::NAME => 'name',
|
||||||
@@ -123,8 +122,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
|
|||||||
'UTF-8',
|
'UTF-8',
|
||||||
array(
|
array(
|
||||||
"\nclass Monkey extends Mustache_Template",
|
"\nclass Monkey extends Mustache_Template",
|
||||||
'$buffer .= $indent . \'foo\'',
|
"\$buffer .= \$indent . 'foo\n';",
|
||||||
'$buffer .= "\n"',
|
|
||||||
'$value = $this->resolveValue($context->find(\'name\'), $context, $indent);',
|
'$value = $this->resolveValue($context->find(\'name\'), $context, $indent);',
|
||||||
'$buffer .= htmlspecialchars($value, '.ENT_COMPAT.', \'UTF-8\');',
|
'$buffer .= htmlspecialchars($value, '.ENT_COMPAT.', \'UTF-8\');',
|
||||||
'$value = $this->resolveValue($context->last(), $context, $indent);',
|
'$value = $this->resolveValue($context->last(), $context, $indent);',
|
||||||
|
|||||||
Reference in New Issue
Block a user