当前位置: 首页>>代码示例>>PHP>>正文


PHP BladeCompiler::extend方法代码示例

本文整理汇总了PHP中Illuminate\View\Compilers\BladeCompiler::extend方法的典型用法代码示例。如果您正苦于以下问题:PHP BladeCompiler::extend方法的具体用法?PHP BladeCompiler::extend怎么用?PHP BladeCompiler::extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\View\Compilers\BladeCompiler的用法示例。


在下文中一共展示了BladeCompiler::extend方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: registerBlade

 /**
  * Register blade syntax for a specific widget.
  *
  * @param string $name
  */
 protected function registerBlade($name)
 {
     $this->blade->extend(function ($view, $compiler) use($name) {
         $pattern = $this->createMatcher($name);
         $replace = '$1<?php echo Widget::' . $name . '$2; ?>';
         return preg_replace($pattern, $replace, $view);
     });
 }
开发者ID:shammadahmed,项目名称:sky,代码行数:13,代码来源:Widget.php

示例2: registerTag

 /**
  * Register Blade syntax for a specific component.
  *
  * @param  string $method
  * @param  string $namespace
  * @return void
  */
 protected function registerTag($method, $namespace = '')
 {
     $this->blade->extend(function ($view, $compiler) use($method, $namespace) {
         $pattern = $compiler->createMatcher('component_' . $method);
         $replace = '$1<?php echo ' . $namespace . $method . '$2; ?>';
         return preg_replace($pattern, $replace, $view);
     });
 }
开发者ID:suhe,项目名称:bdoportal,代码行数:15,代码来源:Components.php

示例3: addLoopControlDirectives

 /**
  * Extend blade by continue and break directives.
  *
  * @param  BladeCompiler $blade
  *
  * @return BladeCompiler
  */
 private function addLoopControlDirectives(BladeCompiler $blade)
 {
     $blade->extend(function ($value) {
         $pattern = '/(?<!\\w)(\\s*)@continue\\s*\\(([^)]*)\\)/';
         $replacement = '$1<?php if ($2) { continue; } ?>';
         return preg_replace($pattern, $replacement, $value);
     });
     $blade->extend(function ($value) {
         $pattern = '/(?<!\\w)(\\s*)@break\\s*\\(([^)]*)\\)/';
         $replacement = '$1<?php if ($2) { break; } ?>';
         return preg_replace($pattern, $replacement, $value);
     });
     return $blade;
 }
开发者ID:advmaker,项目名称:blade-loop,代码行数:21,代码来源:BladeLoopServiceProvider.php

示例4: addBladeViewTesting

 /**
  * Adds all class methods prefixed with assert* as blade view directives
  * and assigns the $view and $blade class properties
  *
  * @param string $viewDirectoryPath The path to the directory containing test views
  */
 public function addBladeViewTesting($viewDirectoryPath = null)
 {
     /** @var \Illuminate\View\Factory $view */
     $view = $this->app['view'];
     // Add instance of current test class, this enable to call assert functions in views
     $view->share('testClassInstance', $this);
     // Lets make those assertions callable by fancy blade directives, nom nom nom
     $this->blade = $view->getEngineResolver()->resolve('blade')->getCompiler();
     $this->blade->extend(function ($value) {
         return preg_replace('/@assert(\\w*)\\((.*)\\)/', "<?php \$testClassInstance->assert\$1(\$2); ?>", $value);
     });
     if ($viewDirectoryPath !== null) {
         $view->addLocation($viewDirectoryPath);
     }
 }
开发者ID:laradic,项目名称:dev,代码行数:21,代码来源:BladeViewTestingTrait.php

示例5: extend

 /**
  * Turn $this->extend() into @extend().
  */
 protected function extend()
 {
     $this->compiler->extend(function ($view, $compiler) {
         $pattern = $compiler->createMatcher('extend');
         return preg_replace($pattern, '$1<?php echo $_view->extend$2; ?>', $view);
     });
 }
开发者ID:rachid804,项目名称:BladeView,代码行数:10,代码来源:Extensions.php

示例6: registerSearchForm

    protected function registerSearchForm(Compiler $blade, $name)
    {
        $blade->extend(function ($view, $compiler) use($name) {
            $pattern = $compiler->createMatcher($name);
            $code = <<<'EOD'
                    $1<?php
                    if (isset($searchForm)) {
                        echo $searchForm;
                    } else{
                        $passed = array$2;
                        if (count($passed) == 2) {
                            $m = $passed[0];
                            $res = $passed[1];
                        }
                        if (count($passed) == 1) {
                            $m = $passed[0];
                            $res = isset($resource) ? $resource : null;
                        }
                        if (count($passed) == 0) {
                            $m = isset($model) ? $model : null;
                            $res = isset($resource) ? $resource : null;
                        }
                        echo Resource::searchForm($m, $res);
                    }
                ?>
EOD;
            return preg_replace($pattern, $code, $view);
        });
    }
开发者ID:realholgi,项目名称:cmsable,代码行数:29,代码来源:ResourceDirectives.php

示例7: registerDoShortcode

 /**
  * @shortcode
  *
  * @param BladeCompiler $compiler The blade compiler to extend
  */
 private function registerDoShortcode($compiler)
 {
     $compiler->extend(function ($view, $comp) {
         $pattern = $comp->createMatcher('shortcode');
         $replacement = '$1<?php do_shortcode($2); ?> ';
         return preg_replace($pattern, $replacement, $view);
     });
 }
开发者ID:jubstuff,项目名称:baobab,代码行数:13,代码来源:WordPressShortcodeExtension.php

示例8: registerEndLoop

 /**
  * @wpend
  *
  * @param BladeCompiler $compiler The blade compiler to extend
  */
 private function registerEndLoop($compiler)
 {
     $compiler->extend(function ($view, $comp) {
         $pattern = $comp->createPlainMatcher('endwploop');
         $replacement = '$1<?php endif; wp_reset_postdata(); ?>';
         return preg_replace($pattern, $replacement, $view);
     });
 }
开发者ID:jubstuff,项目名称:baobab,代码行数:13,代码来源:WordPressLoopExtension.php

示例9: extendBlade

 /**
  * Add extra functionality to the blade templating compiler.
  *
  * @param BladeCompiler $blade The compiler to extend
  *
  * @return void
  */
 public static function extendBlade(BladeCompiler $blade)
 {
     $keywords = ["namespace", "use"];
     foreach ($keywords as $keyword) {
         $blade->extend(function ($view, $compiler) use($keyword) {
             $pattern = $compiler->createMatcher($keyword);
             return preg_replace_callback($pattern, function ($matches) use($keyword) {
                 return $matches[1] . "<?php {$keyword} " . substr($matches[2], 1, -1) . " ?>";
             }, $view);
         });
     }
     $assetify = function ($file, $type) {
         $file = trim($file, "()");
         if (in_array(substr($file, 0, 1), ["'", '"'], true)) {
             $file = trim($file, "'\"");
         } else {
             return "{{ {$file} }}";
         }
         if (substr($file, 0, 1) !== "/") {
             $file = "/{$type}/{$file}";
         }
         if (substr($file, (strlen($type) + 1) * -1) !== ".{$type}") {
             $file .= ".{$type}";
         }
         return $file;
     };
     $blade->extend(function ($view, $compiler) use($assetify) {
         $pattern = $compiler->createMatcher("css");
         return preg_replace_callback($pattern, function ($matches) use($assetify) {
             $file = $assetify($matches[2], "css");
             return "<link rel='stylesheet' type='text/css' href='{$file}'>";
         }, $view);
     });
     $blade->extend(function ($view, $compiler) use($assetify) {
         $pattern = $compiler->createMatcher("js");
         return preg_replace_callback($pattern, function ($matches) use($assetify) {
             $file = $assetify($matches[2], "js");
             return "<script type='text/javascript' src='{$file}'></script>";
         }, $view);
     });
 }
开发者ID:Alewex,项目名称:blade,代码行数:48,代码来源:Blade.php

示例10: register

 protected function register()
 {
     $rules = [BladedSyntax::STATEMENT => $this->getStateParser(), BladedSyntax::CONDITION => $this->getConditionParser(), BladedSyntax::CONDITION_UNLESS => $this->getUnlessConditionParser(), BladedSyntax::CONDITION_ELSE => function () {
         return '<?php else: ?>';
     }, BladedSyntax::CONDITION_END => function () {
         return '<?php endif; ?>';
     }, BladedSyntax::ITERATORS => $this->getIteratorParser(), BladedSyntax::ITERATORS_END => $this->getIteratorEndParser(), BladedSyntax::STATEMENT_CACHED => $this->getCacheStateParser(), BladedSyntax::TEMPLATE => $this->getTemplateParser(), BladedSyntax::TEMPLATE_CACHED => $this->getCacheTplParser()];
     $this->blade->extend(function ($view) use($rules) {
         foreach ($rules as $regexp => $callback) {
             $view = preg_replace_callback($regexp, $callback, $view);
         }
         return $view;
     });
 }
开发者ID:laravel-commode,项目名称:bladed,代码行数:14,代码来源:BladedCompiler.php

示例11: extend

 /**
  * extend
  *
  * @param   BladeCompiler $blade
  * @param   string        $name
  * @param   callable      $closure
  *
  * @return  void
  */
 public static function extend(BladeCompiler $blade, $name, $closure)
 {
     // For 5.0 after
     if (is_callable(array($blade, 'directive'))) {
         $blade->directive($name, $closure);
         return;
     }
     // For 4.x before
     $blade->extend(function ($view, BladeCompiler $compiler) use($name, $closure) {
         $pattern = $compiler->createMatcher($name);
         return preg_replace_callback($pattern, function ($matches) use($closure) {
             if (empty($matches[2])) {
                 return $matches[0];
             }
             return $matches[1] . $closure($matches[2]);
         }, $view);
     });
     return;
 }
开发者ID:im286er,项目名称:windwalker,代码行数:28,代码来源:BladeExtending.php

示例12: extend

 /**
  * Register a custom Blade compiler.
  *
  * @param callable $compiler
  * @return void 
  * @static 
  */
 public static function extend($compiler)
 {
     \Illuminate\View\Compilers\BladeCompiler::extend($compiler);
 }
开发者ID:satriashp,项目名称:tour,代码行数:11,代码来源:_ide_helper.php

示例13: registerRawPhpBraces

 /**
  * @shortcode
  *
  * @param BladeCompiler $compiler The blade compiler to extend
  */
 private function registerRawPhpBraces($compiler)
 {
     $compiler->extend(function ($view, $comp) {
         return preg_replace('/#\\{\\{\\s*(.+?)\\s*\\}\\}/s', '<?php $1; ?>', $view);
     });
 }
开发者ID:jubstuff,项目名称:baobab,代码行数:11,代码来源:RawPhpExtension.php


注:本文中的Illuminate\View\Compilers\BladeCompiler::extend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。