jeudi 25 janvier 2018

Store html string including variable name in db and then insert into blade view

I want to store templates as html string with PHP variables in my DB. So far I'm already storing things like that

<h1>Hello</h1> 

<p>This is entity n°  and the user responsible is <b> </b></p>

In my controller I use something like this

$template = \App\Template::find(1);
$entity = \App\Entity::find(1);
return view('home' , compact('template' , 'entity'));

And in my view I use

{!! $template->html !!}

The HTML is well rendered but my PHP variables are still displayed like this

This is not working and I understand why. I'm trying to render a php variable while it's being parsed.

But I don't know how to proceed to render the PHP before passing it to the view... Any idea?

Or am I doing a silly thing and there is another way to proceed?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire