Hello,
I am trying to parse blade from a database value but it just doesn't work. I have a template for my posts, and in this template, it returns the post content using {{ $post->content }}. The $post->content contains something like {{ time() }} for example.
The problem is, it just puts the generated PHP code into the browser. It does not echo it, it just places it in the source code like this:
<!-- BLOG POST CONTENT START -->
<h1>Hosting</h1>
<?php echo time(); ?>
I am trying to echo it using this code from my template:
{{ Blade::compileString($post->content); }}
Does someone have any idea if it is even possible to do it like this?
Thanks!
mengidd said:
Try using {!! !!} instead.
Thanks for your reply. I forgot to mention that I'm running Laravel 4. It's not escaped so that could not be the problem.
This does not get evaluated by default. You have to eval() it yourself.
edit: check this http://sharpten.com/blog/2014/08/15/explicitly-parsing-blade-code-laravel-4.html#sthash.m9JIliFb.dpbs
Thanks for your reply.
I have seen that one indeed, but I do not know where to put the code.. do you have any idea where I could/should put it? Also I tried to use eval() while echoing the $post->content, it just didn't do anything. Just a white space. Maybe this is a fix for the problem I had.
Giovani
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community