123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
-
- namespace Illuminate\View\Compilers\Concerns;
-
- use Illuminate\View\Factory as ViewFactory;
-
- trait CompilesLayouts
- {
- /**
- * The name of the last section that was started.
- *
- * @var string
- */
- protected $lastSection;
-
- /**
- * Compile the extends statements into valid PHP.
- *
- * @param string $expression
- * @return string
- */
- protected function compileExtends($expression)
- {
- $expression = $this->stripParentheses($expression);
-
- $echo = "<?php echo \$__env->make({$expression}, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
-
- $this->footer[] = $echo;
-
- return '';
- }
-
- /**
- * Compile the section statements into valid PHP.
- *
- * @param string $expression
- * @return string
- */
- protected function compileSection($expression)
- {
- $this->lastSection = trim($expression, "()'\" ");
-
- return "<?php \$__env->startSection{$expression}; ?>";
- }
-
- /**
- * Replace the @parent directive to a placeholder.
- *
- * @return string
- */
- protected function compileParent()
- {
- return ViewFactory::parentPlaceholder($this->lastSection ?: '');
- }
-
- /**
- * Compile the yield statements into valid PHP.
- *
- * @param string $expression
- * @return string
- */
- protected function compileYield($expression)
- {
- return "<?php echo \$__env->yieldContent{$expression}; ?>";
- }
-
- /**
- * Compile the show statements into valid PHP.
- *
- * @return string
- */
- protected function compileShow()
- {
- return '<?php echo $__env->yieldSection(); ?>';
- }
-
- /**
- * Compile the append statements into valid PHP.
- *
- * @return string
- */
- protected function compileAppend()
- {
- return '<?php $__env->appendSection(); ?>';
- }
-
- /**
- * Compile the overwrite statements into valid PHP.
- *
- * @return string
- */
- protected function compileOverwrite()
- {
- return '<?php $__env->stopSection(true); ?>';
- }
-
- /**
- * Compile the stop statements into valid PHP.
- *
- * @return string
- */
- protected function compileStop()
- {
- return '<?php $__env->stopSection(); ?>';
- }
-
- /**
- * Compile the end-section statements into valid PHP.
- *
- * @return string
- */
- protected function compileEndsection()
- {
- return '<?php $__env->stopSection(); ?>';
- }
- }
|