Skip to content

Commit 0672e3f

Browse files
committed
add hook
1 parent f075dea commit 0672e3f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Illuminate/View/Compilers/BladeCompiler.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ class BladeCompiler extends Compiler implements CompilerInterface
5656
*/
5757
protected $conditions = [];
5858

59+
/**
60+
* The registered string preparation callbacks.
61+
*
62+
* @var array
63+
*/
64+
protected $prepareStringsForCompilationUsing = [];
65+
5966
/**
6067
* All of the registered precompilers.
6168
*
@@ -249,6 +256,10 @@ public function compileString($value)
249256
{
250257
[$this->footer, $result] = [[], ''];
251258

259+
foreach ($this->prepareStringsForCompilationUsing as $callback) {
260+
$value = $callback($value);
261+
}
262+
252263
// First we will compile the Blade component tags. This is a precompile style
253264
// step which compiles the component Blade tags into @component directives
254265
// that may be used by Blade. Then we should call any other precompilers.
@@ -947,6 +958,19 @@ public function getCustomDirectives()
947958
return $this->customDirectives;
948959
}
949960

961+
/**
962+
* Indicate that the following callable should be used to prepare strings for compilation.
963+
*
964+
* @param callable $callback
965+
* @return $this
966+
*/
967+
public function prepareStringsForCompilationUsing(callable $callback)
968+
{
969+
$this->prepareStringsForCompilationUsing[] = $callback;
970+
971+
return $this;
972+
}
973+
950974
/**
951975
* Register a new precompiler.
952976
*

0 commit comments

Comments
 (0)