TinyMCE和Laravel [英] TinyMCE and Laravel
问题描述
我正在尝试在我的Laravel项目中使用tinyMCE.问题是当我存储新文章时html标记不起作用.它们在我的laravel视图中像纯文本一样显示:
I'm trying to use tinyMCE with my Laravel project. The problem is when I store the new article the html tags are not working. They're showing up like a plain text on display on my laravel view:
这是在create.blade.php中实现的代码:
This is the code implemented in create.blade.php:
<script type="text/javascript" src="{{ asset('/js/tinymce/tinymce.min.js') }}"></script>
<script type="text/javascript">
tinymce.init({
selector : "textarea",
plugins : ["advlist autolink lists link image charmap print preview anchor", "searchreplace visualblocks code fullscreen", "insertdatetime media table contextmenu paste jbimages"],
toolbar : "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image jbimages",
});
</script>
推荐答案
标记在Laravel中默认转义.如果您要在包含标记的数据库中存储文本,则可以将一种吸气剂应用于Eloquent模型以使其不为您所用,或者使用以下Blade语法:
Markup is escaped by default in Laravel. If you're storing text in your database that contains markup, you will either want to apply a getter to your Eloquent Model that will unescape it for you, or use the following Blade syntax:
{!! $model->text !!}
在处理未转义的输出时,我强烈建议通过使用 valid_elements 属性.
When dealing with unescaped output, I would highly recommend limiting the tags that can be applied in your TinyMCE editor by using the valid_elements attribute.
这篇关于TinyMCE和Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!