| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace Illuminate\View\Compilers\Concerns;
|
|
|
4 |
|
|
|
5 |
trait CompilesIncludes
|
|
|
6 |
{
|
|
|
7 |
/**
|
|
|
8 |
* Compile the each statements into valid PHP.
|
|
|
9 |
*
|
|
|
10 |
* @param string $expression
|
|
|
11 |
* @return string
|
|
|
12 |
*/
|
|
|
13 |
protected function compileEach($expression)
|
|
|
14 |
{
|
|
|
15 |
return "<?php echo \$__env->renderEach{$expression}; ?>";
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
/**
|
|
|
19 |
* Compile the include statements into valid PHP.
|
|
|
20 |
*
|
|
|
21 |
* @param string $expression
|
|
|
22 |
* @return string
|
|
|
23 |
*/
|
|
|
24 |
protected function compileInclude($expression)
|
|
|
25 |
{
|
|
|
26 |
$expression = $this->stripParentheses($expression);
|
|
|
27 |
|
|
|
28 |
return "<?php echo \$__env->make({$expression}, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>";
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* Compile the include-if statements into valid PHP.
|
|
|
33 |
*
|
|
|
34 |
* @param string $expression
|
|
|
35 |
* @return string
|
|
|
36 |
*/
|
|
|
37 |
protected function compileIncludeIf($expression)
|
|
|
38 |
{
|
|
|
39 |
$expression = $this->stripParentheses($expression);
|
|
|
40 |
|
|
|
41 |
return "<?php if (\$__env->exists({$expression})) echo \$__env->make({$expression}, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>";
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
* Compile the include-when statements into valid PHP.
|
|
|
46 |
*
|
|
|
47 |
* @param string $expression
|
|
|
48 |
* @return string
|
|
|
49 |
*/
|
|
|
50 |
protected function compileIncludeWhen($expression)
|
|
|
51 |
{
|
|
|
52 |
$expression = $this->stripParentheses($expression);
|
|
|
53 |
|
|
|
54 |
return "<?php echo \$__env->renderWhen($expression, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path'])); ?>";
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
* Compile the include-unless statements into valid PHP.
|
|
|
59 |
*
|
|
|
60 |
* @param string $expression
|
|
|
61 |
* @return string
|
|
|
62 |
*/
|
|
|
63 |
protected function compileIncludeUnless($expression)
|
|
|
64 |
{
|
|
|
65 |
$expression = $this->stripParentheses($expression);
|
|
|
66 |
|
|
|
67 |
return "<?php echo \$__env->renderUnless($expression, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path'])); ?>";
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
/**
|
|
|
71 |
* Compile the include-first statements into valid PHP.
|
|
|
72 |
*
|
|
|
73 |
* @param string $expression
|
|
|
74 |
* @return string
|
|
|
75 |
*/
|
|
|
76 |
protected function compileIncludeFirst($expression)
|
|
|
77 |
{
|
|
|
78 |
$expression = $this->stripParentheses($expression);
|
|
|
79 |
|
|
|
80 |
return "<?php echo \$__env->first({$expression}, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>";
|
|
|
81 |
}
|
|
|
82 |
}
|