Posted by Arjun on Tuesday 24th February 2015

Define Variable In Blade Templates Laravel?

Blade did not provided a way to define variables.But you can extend blade by using extend method as shown below

Blade::extend(function($value) {
    return preg_replace('/\@var(.+)/', '<?php ${1}; ?>', $value);
});

How to use

@var $variableName = "variableValue"

That's it.