Support the ongoing development of Laravel.io →
posted 9 years ago
Views Blade
Last updated 2 years ago.
0

It's much better approach to store printf format string instead of anything for eval. So you could store the string like this:

$format = 'Hello, %s';

And then echo it:

{{ sprintf($format, $first_name) }}

Or, even better, to prepare string in controller and pass it to the view.

Last updated 2 years ago.
0

The issue is that I'd need to be able to specify what variable I want injected, from the content of the string. Looks like my only option is pre-processing the string from the controller before the view gets rendered.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

eheaton eheaton Joined 29 Aug 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.