Automatically apply entitiesto output using blade

By using 3 braces instead of 2, you can now automatically apply
HTML::entities() to any output
This commit is contained in:
theshiftexchange 2012-12-17 02:38:06 +11:00
parent 8ff052cbdb
commit 8fe6158058
2 changed files with 6 additions and 0 deletions

View File

@ -197,6 +197,8 @@ protected static function compile_comments($value)
*/
protected static function compile_echos($value)
{
$value = preg_replace('/\{\{\{(.+?)\}\}\}/', '<?php echo HTML::entities($1); ?>', $value);
return preg_replace('/\{\{(.+?)\}\}/', '<?php echo $1; ?>', $value);
}

View File

@ -13,9 +13,13 @@ public function testEchosAreConvertedProperly()
{
$blade1 = '{{$a}}';
$blade2 = '{{e($a)}}';
$blade3 = '{{{$a}}}';
$blade4 = '{{{e($a)}}}';
$this->assertEquals('<?php echo $a; ?>', Blade::compile_string($blade1));
$this->assertEquals('<?php echo e($a); ?>', Blade::compile_string($blade2));
$this->assertEquals('<?php echo HTML::entities($a); ?>', Blade::compile_string($blade3));
$this->assertEquals('<?php echo HTML::entities(e($a)); ?>', Blade::compile_string($blade4));
}
/**