Skip to content
Discussion options

You must be logged in to vote

You can use the compileString method.

Blade::compileString('This is @if (true) working @else not working @endif')

This will evaluate into: 'This is <?php if(true): ?> working <?php else: ?> not working <?php endif; ?>'. You can put this content then in a file and store it somewhere. When you need this just @include it in your view.

If you compile Blade a user has written in a texteditor remember he could use variables he is not supposed to or display data he is not supposed to.

Blade::compileString('@foreach (User::all() as $user) <div>{{ $user->email }}: {{ $user->some_secret_token }}</div> @endforeach')

This code would display a list of all users with their email address and some secret…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by crynobone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants