我在这个问题.现在我必须找到一种方法来覆盖默认的刀片转义功能.我认为有一种方法可以创建一个扩展和覆盖 BladeCompiler 类行为的类,这样我就可以做这样的事情:
I almost solved my problem in this question. Now I must find a way to override the default blade escape function. I think there's a way to create a class that extends and override the behavior of BladeCompiler class, this way I could make something like this:
class MyCustomCompiler extends BladeCompiler{
function compileEscapedEchos($value){
return parent::compileEscapedEchos(utf8_encode($value));
}
}
如果我能做到,我只需要让 laravel 使用 MyCustomCompiler 而不是 BladeCompiler.我该怎么做?
If I could do it, I only must make laravel use MyCustomCompiler instead BladeCompiler. How can I do it?
您甚至不必重写编译器,只需在服务提供者中执行此操作:
You don't even have to override the compiler, just do this in a Service Provider:
Blade::setEchoFormat('e(utf8_encode(%s))');
这将改变 {{ ... }} 的编译方式.默认格式为e(%s).
This will change how {{ ... }} is compiled. The default format is e(%s).
这篇关于如何覆盖laravel 5中刀片的默认转义功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Laravel Eloquent Union 查询Laravel Eloquent Union query(Laravel Eloquent Union 查询)
覆盖 Laravel 5 辅助函数Overwrite laravel 5 helper function(覆盖 Laravel 5 辅助函数)
laravel querybuilder 如何在 where 函数中使用 likelaravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函数中使用 like)
响应内容必须是实现 __toString()、“boolean"和“The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(响应内容必须是实现 __toS
Laravel 5 的角色,如何只允许管理员访问某些根Roles with laravel 5, how to allow only admin access to some root(Laravel 5 的角色,如何只允许管理员访问某些根)
Laravel Auth - 使用 md5 而不是集成的 Hash::make()Laravel Auth - use md5 instead of the integrated Hash::make()(Laravel Auth - 使用 md5 而不是集成的 Hash::make())