diff --git a/src/Handlebars/Template.php b/src/Handlebars/Template.php
index 20ef957..cca10ba 100644
--- a/src/Handlebars/Template.php
+++ b/src/Handlebars/Template.php
@@ -629,7 +629,7 @@ class Template
if (is_array($value)) {
return 'Array';
}
- if ($escaped) {
+ if ($escaped && !($value instanceof SafeString)) {
$args = $this->handlebars->getEscapeArgs();
array_unshift($args, (string)$value);
$value = call_user_func_array(
diff --git a/tests/Xamin/HandlebarsTest.php b/tests/Xamin/HandlebarsTest.php
index 1d91e1b..5fe8bb4 100644
--- a/tests/Xamin/HandlebarsTest.php
+++ b/tests/Xamin/HandlebarsTest.php
@@ -576,6 +576,20 @@ class HandlebarsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('new', $string->getString());
}
+ /**
+ * test SafeString class
+ */
+ public function testSafeStringClass()
+ {
+ $loader = new \Handlebars\Loader\StringLoader();
+ $helpers = new \Handlebars\Helpers();
+ $engine = new \Handlebars\Handlebars(array('loader' => $loader, 'helpers' => $helpers));
+
+ $this->assertEquals('Test', $engine->render('{{string}}', array(
+ 'string' => new \Handlebars\SafeString('Test')
+ )));
+ }
+
/**
* @param $dir
*