Reputation: 1333
I have a helper function with the following
Note I am using the following to parse content
https://github.com/erusev/parsedown
function display_docs_page($name){
// Get Docs URL
$docs_url = config('docs.docs_url');
// Get File URL
$file_url = $docs_url.'/'.$name.'.md';
// Check If File Exists
if (file_exists($file_url)) {
// get raw file data
$raw_file_data = file_get_contents($file_url);
// convert data to html
$parsedown = new Parsedown();
return $parsedown->text($raw_file_data);
} else {
// 404
return 'not_found';
}
}
However when I run my function
return view('greeting', [
'contents' => display_docs_page(config('general.homepage')),
]);
and try to echo out the variable so in blade
{{ $contents }}
I just just RAW html code. So its displaying the html data but its just raw code the browser isn't interpreting it.
Upvotes: 1
Views: 11037
Reputation: 54389
In Lumen / Laravel 5 you should use {!! !!}
to output variable without escaping:
{!! $contents !!}
Read more: http://laravel.com/docs/master/upgrade#upgrade-5.0 (Blade Tag Changes section)
Upvotes: 5
Reputation: 1360
Its because by default laravel escaped everything in {{ }}
, you must use {!! $contents !!}
instead of {{ $contents }}
Upvotes: 0