Example #1
0
 /**
  * Bootstrap.
  *
  * @return void
  */
 public function boot()
 {
     $this->app['events']->listen('kernel.handled', function (Request $req, Response $res) {
         if ($this->app['config']->get('app.debug') && $res->headers->has('Content-Type') && strpos($res->headers->get('Content-Type'), 'html') !== false) {
             $res->setContent(Template::tidy($res->getContent()));
         }
     });
 }
Example #2
0
 /**
  * Compile the view at the given path.
  *
  * @param  string $path
  * @return void
  */
 public function compile($path)
 {
     $file = $this->files->get($path);
     $contents = Template::compile($file);
     if (!is_null($this->cachePath)) {
         $compiledPath = $this->getCompiledPath($path);
         $this->files->put($compiledPath, $contents);
     }
 }
Example #3
0
 static function parse($tree)
 {
     extract($tree);
     if ($bool == '!') {
         $statement = "! ( {$statement} )";
     }
     $node = Block::parse($node);
     $children = Template::parse($children);
     return "<?php if ({$statement}): ?>{$node}{$children}<?php endif; ?>";
 }
Example #4
0
 static function parse($tree)
 {
     extract($tree);
     $attributes = static::setAttributes($attributes);
     $content = static::setContent($content);
     $children = Template::parse($children);
     if (static::isSelfClosingTag($tagName)) {
         return "<{$tagName}{$attributes} />";
     }
     return "<{$tagName}{$attributes}>{$content}{$children}</{$tagName}>";
 }
Example #5
0
 static function parse($tree)
 {
     extract($tree);
     $section = addcslashes($section, '"');
     $content = static::setContent($content);
     $children = Template::parse($children);
     $output = "<?php \$__env->startSection(\"{$section}\"); ?>";
     $output .= $content . $children;
     $output .= '<?php $__env->stopSection(); ?>';
     return $output;
 }
Example #6
0
 static function parse($tree)
 {
     extract($tree);
     $section = addcslashes($section, '"');
     $content = static::setContent($content);
     $children = Template::parse($children);
     $output = "<?php ob_start() ?>{$content}{$children}";
     $output .= '<?php $__tmp = ob_get_clean(); ?>';
     $output .= '<?= $__env->yieldContent("' . $section . '") ?: $__tmp ?>';
     $output .= '<?php unset($__tmp); ?>';
     return $output;
 }
Example #7
0
 static function parse($tree)
 {
     extract($tree);
     $view = addcslashes($view, '"');
     $attributes = static::setAttributes($attributes);
     $children = Template::parse($children);
     $output = $children;
     $output .= "<?php extract({$attributes}); ?>";
     $output .= '<?php $__d = array_except(get_defined_vars(), array("__data", "__path")) ?>';
     $output .= "<?= \$__env->make(\"{$view}\", \$__d)->render(); ?>";
     $output .= '<?php unset($__d) ?>';
     return $output;
 }
Example #8
0
 static function parse($tree)
 {
     extract($tree);
     if (!$individual) {
         $individual = preg_match('/^\\$\\w+$/', $iterable) ? '$' . singular(trim($iterable, '$')) : '$item';
     }
     if ($individual == $iterable) {
         $individual = '$item';
     }
     $opening = "<?php foreach({$iterable} as \$i => {$individual}): ?>";
     $node = Block::parse($node);
     $children = Template::parse($children);
     $closing = "<?php endforeach; ?>";
     return $opening . $node . $children . $closing;
 }
Example #9
0
 static function parse($tree)
 {
     extract($tree);
     $view = addcslashes($view, '"');
     $attributes = static::setAttributes($attributes);
     $content = static::setContent($content);
     $children = Template::parse($children);
     $output = "<?php ob_start() ?>{$content}{$children}";
     $output .= '<?php $__tmp = ob_get_clean(); ?>';
     $output .= "<?php extract({$attributes}); ?>";
     $output .= '<?php $__d = array_except(get_defined_vars(), array("__data", "__path")) ?>';
     $output .= '<?= $__env->make("' . $view . '", $__d)->render() ?: $__tmp ?>';
     $output .= '<?php unset($__tmp, $__d); ?>';
     return $output;
 }