MoFish's avatar

Blade::render() with data?

Hi,

I am currently rendering a view using html passed in from a db table using the following code:

$html = replace_tags_helper($data->source);
file_put_contents(resource_path("/views/".$this->file.".blade.php"), trim($html));
return view($this->file)->with('data', $data);

This is creating a temporary view file and rendering it. This makes me doubt it's performance.

I stumbled across Blade::render(). I hoped that I could use this instead of creating a physical view file.

I have tried passing data into this but i could not get it to work.

$html = replace_tags_helper($data->source);
return Blade::render($html)->with('data', $data);

Does anyone know how If its possible to pass $data into blade::render or have an alternative suggestion to how i could achive this?

Thanks

0 likes
3 replies
MoFish's avatar

I swore i tried that and it never worked! I'm so stupid!

Thanks!

Please or to participate in this conversation.