コード例 #1
0
 /**
  * @param  \Box\Brainy\Compiler\TemplateCompiler $compiler A compiler reference
  * @param  array|null                            $args     Arguments
  * @return mixed
  */
 public static function compileOpen(\Box\Brainy\Compiler\TemplateCompiler $compiler, $args)
 {
     $levels = self::getOptionalArg($args, 'levels');
     if (!$levels && isset($args[0])) {
         $compiler->assertIsNotStrict('Continue shorthand is not allowed in strict mode. Use the levels="" attribute instead.');
         $levels = $args[0];
     }
     if ($levels) {
         return "continue {$levels};\n";
     }
     return "continue;\n";
 }
コード例 #2
0
 /**
  * @param  \Box\Brainy\Compiler\TemplateCompiler $compiler A compiler reference
  * @param  array|null                            $args     Arguments
  * @return mixed
  */
 protected static function getName($compiler, $args)
 {
     try {
         return self::getRequiredArg($args, 'name');
     } catch (\Box\Brainy\Exceptions\SmartyCompilerException $e) {
         $compiler->assertIsNotStrict('Block shorthand is not allowed in strict mode. Use the name="" attribute instead.');
         if (!isset($args[0])) {
             throw $e;
         }
         return $args[0];
     }
 }
コード例 #3
0
ファイル: ConstructCapture.php プロジェクト: jeantimex/brainy
 /**
  * @param  \Box\Brainy\Compiler\TemplateCompiler $compiler A compiler reference
  * @param  array|null                            $args     Arguments
  * @return mixed
  */
 public static function compileOpen(\Box\Brainy\Compiler\TemplateCompiler $compiler, $args)
 {
     $name = self::getOptionalArg($args, 'name');
     $assign = self::getOptionalArg($args, 'assign');
     if (!$name && !$assign && isset($args[0])) {
         $compiler->assertIsNotStrict('Capture shorthand is not allowed in strict mode. Use the name="" attribute instead.');
         $name = $args[0];
     }
     if (!$name && !$assign) {
         $name = "'default'";
     }
     if ($name && $assign) {
         throw new \Box\Brainy\Exceptions\SmartyCompilerException('{capture} tags may not set both `name` and `assign`');
     }
     self::openTag($compiler, 'capture', array($name, $assign));
     return "ob_start();\n";
 }
コード例 #4
0
ファイル: ConstructInclude.php プロジェクト: jeantimex/brainy
 /**
  * Compiles the opening tag for a function
  * @param  \Box\Brainy\Compiler\TemplateCompiler $compiler A compiler reference
  * @param  array|null                            $args     Arguments
  * @return mixed
  */
 public static function compileOpen(\Box\Brainy\Compiler\TemplateCompiler $compiler, $args)
 {
     try {
         $file = self::getRequiredArg($args, 'file');
     } catch (SmartyCompilerException $e) {
         $compiler->assertIsNotStrict('Include shorthand is not allowed in strict mode. Use the file="" attribute instead.');
         if (!isset($args[0])) {
             throw $e;
         }
         $file = $args[0];
     }
     $file = (string) $file;
     $assign = self::getOptionalArg($args, 'assign');
     $compileID = self::getOptionalArg($args, 'compile_id', var_export($compiler->smarty->compile_id, true));
     $scope = ConstructAssign::getScope($args, Brainy::SCOPE_LOCAL);
     if (!$assign) {
         return self::getDisplayCode($file, $compileID, $scope, $args);
     }
     $output = 'ob_start();';
     $output .= self::getDisplayCode($file, $compileID, $scope, $args);
     $output .= "\$_smarty_tpl->assign({$assign}, ob_get_clean(), {$scope});\n";
     return $output;
 }