Setting the Content Tags Blade Uses


You want to use different content tags in your Blade template.

You know that blade uses {{ and }} to specify content to be output, but this conflicts with Mustache or some other library you're using.


Use the Blade::setContentTags() method.

Let's say you want to use [% and %] for your tags. First call the method.

Blade::setContentTags('[%', '%]');

Then your template can contain code like.

The value of $variable is [% $variable %].

You can also pass a second argument as true to indicate you're setting the tags to escape content.

Blade::setContentTags('[-%', '%-]', true);

Then instad of using {{{ and }}} you can use [-% and %-].

The value of $variable is [-% $variable %-].


You must call Blade::setContentTags() before using a view.

The two best places to call this are in a service provider or in app/start/global.php.

comments powered by Disqus