Just playing about with Laravel 5, and am having difficulties using the Blade templating syntax. It appears that all my special characters are being escaped. Have I something wrong with my setup?
Just to show my setup, I have added the following to config/app.php
:
Aliases: 'Form' => 'Illuminate\Html\FormFacade', 'Html' => 'Illuminate\Html\HtmlFacade'
Service Providers: 'Illuminate\Html\HtmlServiceProvider'
Now here's my blade view:
@extends('layout')
@section('content')
{{ Form::open() }}
{{ Form::close() }}
@stop
And here is the output in the browser:
<form method="POST" action="http://test.app:8000/categories/create" accept-charset="UTF-8"><input name="_token" type="hidden" value="m4RdpqdbbqQ2F7iwfDkSDKTzEmaBGNvpJbj5LnqE"> </form>
And here is the output from view-source:
<!doctype HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>My Site</title>
</head>
<body>
<header></header>
<content>
<form method="POST" action="http://test.app:8000/categories/create" accept-charset="UTF-8"><input name="_token" type="hidden" value="m4RdpqdbbqQ2F7iwfDkSDKTzEmaBGNvpJbj5LnqE">
</form>
</content>
</body>
</html>
In Laravel 5,
{{ }}
will auto escape. What you need to use now is{!! !!}
.More read about the change can be seen on https://laracasts.com/discuss/channels/general-discussion/new-blade-tag-for-unescaped-data-thoughts (thanks to @user1960364).
If you must use the old (L4.2 or less) Blade syntax, add the following lines at the bottom of AppServiceProvider@register:
This should not be done lightly, and may make your application more vulnerable to XSS exploits, so use it with caution.