问题
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:
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>
回答1:
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 !!}
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.
来源:https://stackoverflow.com/questions/31224938/tinymce-and-laravel