Last active
August 29, 2015 13:59
-
-
Save jazzdan/10675121 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'src/Mustache/Autoloader.php'; | |
Mustache_Autoloader::register(); | |
$m = new Mustache_Engine([ | |
'partials' => [ | |
'header' => '<title>{{$title}}Default title{{/title}}</title>', | |
'base' => '<html>{{$header}}{{/header}}{{$content}}{{/content}}</html>' | |
], | |
]); | |
$tpl = <<<'EOS' | |
{{<base}}{{$header}}{{<header}}{{$title}}My page title{{/title}}{{/header}}{{/header}}{{/base}} | |
EOS; | |
echo $m->render($tpl, []); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
outputs: | |
<html><title>My page title</title></html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php | |
index dcc9469..44f877b 100644 | |
--- a/src/Mustache/Compiler.php | |
+++ b/src/Mustache/Compiler.php | |
@@ -213,7 +213,7 @@ class Mustache_Compiler | |
const BLOCK_VAR = ' | |
$value = $this->resolveValue($context->%s(%s), $context, $indent); | |
if($value && !is_array($value) && !is_object($value)) { | |
- $buffer .= %s; | |
+ $buffer .= $value; | |
} else { | |
%s | |
} | |
@@ -223,9 +223,8 @@ class Mustache_Compiler | |
{ | |
$method = 'findInBlock'; | |
$id_str = var_export($id, true); | |
- $value = $this->getEscape(); | |
- return sprintf($this->prepare(self::BLOCK_VAR, $level), $method, $id_str, $value, $this->walk($nodes, 2)); | |
+ return sprintf($this->prepare(self::BLOCK_VAR, $level), $method, $id_str, $this->walk($nodes, 2)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Then it outputs: | |
<html><title>My page title</title></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment