Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Illuminate/View/Compilers/BladeCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -939,17 +939,18 @@ public function aliasInclude($path, $alias = null)
*
* @param string $name
* @param callable $handler
* @param bool $bind
* @return void
*
* @throws \InvalidArgumentException
*/
public function directive($name, callable $handler)
public function directive($name, callable $handler, bool $bind = false)
{
if (! preg_match('/^\w+(?:::\w+)?$/x', $name)) {
throw new InvalidArgumentException("The directive name [{$name}] is not valid. Directive names must only contain alphanumeric characters and underscores.");
}

$this->customDirectives[$name] = $handler;
$this->customDirectives[$name] = $bind ? $handler->bindTo($this, BladeCompiler::class) : $handler;
}

/**
Expand Down