• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Blade类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Blade的典型用法代码示例。如果您正苦于以下问题:PHP Blade类的具体用法?PHP Blade怎么用?PHP Blade使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: view

 /**
  * Метод подключения шаблонов
  * @param  string  $view   имя шаблона
  * @param  array   $params массив параметров
  * @param  boolean $return выводить или возвращать код
  * @return string          сформированный код
  */
 public static function view($template, $params = [], $return = false)
 {
     $blade = new Blade(APP . '/views', STORAGE . '/cache');
     if ($return) {
         return $blade->view()->make($template, $params)->render();
     } else {
         echo $blade->view()->make($template, $params)->render();
     }
 }
开发者ID:visavi,项目名称:rotorcms,代码行数:16,代码来源:App.php


示例2: boot

 public function boot()
 {
     $directivesDirectory = base_path() . '/resources/views/directives';
     // Check if directory exists
     if (!File::exists($directivesDirectory)) {
         return;
     }
     $directivePaths = File::files($directivesDirectory);
     // Check if we have at least one file
     if (empty($directivePaths)) {
         return;
     }
     $regex = $this->buildRegex($directivePaths);
     \Blade::extend(function ($view) use($regex) {
         $offset = 0;
         while (preg_match($regex, $view, $matches, PREG_OFFSET_CAPTURE, $offset)) {
             // Store directive name
             $directiveName = $matches[1][0];
             // Store start and length of pattern
             $patternStart = $matches[0][1];
             $patternLength = strlen($matches[0][0]);
             $expressionStart = $matches[2][1];
             // Fetch expression
             $expr = $this->fetchExpression($view, $expressionStart, $patternStart + $patternLength);
             // Store beginning and end
             $beginning = substr($view, 0, $patternStart);
             $end = substr($view, $expressionStart + strlen($expr) + 1);
             // Construct view
             $view = $beginning . "@include('directives.{$directiveName}', array('param' => ({$expr})))" . $end;
             // Compute new offset to search from
             $offset = $patternStart + strlen($expr);
         }
         return $view;
     });
 }
开发者ID:thejager,项目名称:directives,代码行数:35,代码来源:DirectivesServiceProvider.php


示例3: boot

 /**
  * Bootstrap any application services.
  */
 public function boot()
 {
     \Blade::directive('macro', function ($expression) {
         $pattern = '/(\\([\'|\\"](\\w+)[\'|\\"],\\s*(([^\\@])+|(.*))\\))/xim';
         $matches = [];
         preg_match_all($pattern, $expression, $matches);
         if (!isset($matches[3][0])) {
             throw new \InvalidArgumentException(sprintf('Invalid arguments in blade: macro%s', $expression));
         }
         return sprintf("<?php \$___tiny['%s']=function(%s){ ob_start(); ?>\n", $matches[2][0], $matches[3][0]);
     });
     \Blade::directive('endmacro', function ($expression) {
         return "\n<?php return ob_get_clean();} ?>\n";
     });
     \Blade::directive('usemacro', function ($expression) {
         $pattern = '/(\\([\'|\\"](\\w+)[\'|\\"],\\s*(([^\\@])+|(.*))\\))/xim';
         $matches = [];
         preg_match_all($pattern, $expression, $matches);
         if (!isset($matches[3][0])) {
             throw new \InvalidArgumentException(sprintf('Invalid arguments in blade: usemacro%s', $expression));
         }
         return sprintf("<?php echo \$___tiny['%s'](%s); ?>\n", $matches[2][0], $matches[3][0]);
     });
     \Blade::directive('permission', function ($expression) {
         return "<?php if(Auth::user()->permission{$expression}): ?>";
     });
     \Blade::directive('endpermission', function ($expression) {
         return '<?php endif; ?>';
     });
 }
开发者ID:oliverpool,项目名称:tinyissue,代码行数:33,代码来源:BladeServiceProvider.php


示例4: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     \Blade::setContentTags('{{{', '}}}');
     \Blade::setEscapedContentTags('{{', '}}');
     \Blade::setEchoFormat('nl2br(e(%s))');
     \Form::component('checklist', 'components.form.checklist', ['name', 'options']);
 }
开发者ID:rikmeijer,项目名称:teach.php,代码行数:12,代码来源:AppServiceProvider.php


示例5: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     \Blade::extend(function ($value) {
         $value = preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $value);
         return $value;
     });
 }
开发者ID:synthx,项目名称:infuse,代码行数:12,代码来源:AppServiceProvider.php


示例6: sharpen

 /**
  * Register the Blade view engine with Laravel.
  *
  * @return void
  */
 public static function sharpen()
 {
     Event::listen(View::engine, function ($view) {
         // The Blade view engine should only handle the rendering of views which
         // end with the Blade extension. If the given view does not, we will
         // return false so the View can be rendered as normal.
         if (!str_contains($view->path, BLADE_EXT)) {
             //return;
         }
         $compiled = Blade::compiled($view->path);
         // If the view doesn't exist or has been modified since the last time it
         // was compiled, we will recompile the view into pure PHP from it's
         // Blade representation, writing it to cached storage.
         if (!file_exists($compiled) or Blade::expired($view->view, $view->path)) {
             file_put_contents($compiled, Blade::compile($view));
         }
         $view->mytplengine or $view->mytplengine = new \TemplateEngine(TEMPLATEPATH);
         //kd($compiled);
         $compiled = $view->mytplengine->display($compiled, true);
         $view->path = $compiled;
         // Once the view has been compiled, we can simply set the path to the
         // compiled view on the view instance and call the typical "get"
         // method on the view to evaluate the compiled PHP view.
         return ltrim($view->get());
     });
 }
开发者ID:ycms,项目名称:theme-evo,代码行数:31,代码来源:blade.php


示例7: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     \Blade::setContentTags('<%', '%>');
     // for variables and all things Blade
     \Blade::setEscapedContentTags('<%%', '%%>');
     // for escaped data
 }
开发者ID:andbet39,项目名称:things,代码行数:12,代码来源:AppServiceProvider.php


示例8: register

 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     $this->mergeConfigFrom(__DIR__ . '/../../../config/veer.php', 'veer');
     \Blade::setRawTags('{{', '}}');
     \Blade::setContentTags('{{{', '}}}');
     \Blade::setEscapedContentTags('{{{', '}}}');
 }
开发者ID:artemsk,项目名称:veer-core,代码行数:12,代码来源:AppServiceProvider.php


示例9: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $_this =& $this;
     $this->app->bind('theme.assets', function ($app) {
         return new \Onefasteuro\Theme\Assets(new \Assetic\AssetManager(), $app);
     });
     $this->app->bind('theme.page', function ($app) {
         return new Page\StaticPage($app['config'], $app['theme.assets']);
     });
     $this->app->bind('theme.parser', function ($app) use(&$_this) {
         $parser = Helper::parser($app);
         $class = new \ReflectionClass("\\Onefasteuro\\Theme\\{$parser}");
         $class = $class->newInstance($app['config'], $app['theme.page']);
         return $class;
     });
     $this->app->booting(function () {
         $loader = \Illuminate\Foundation\AliasLoader::getInstance();
         $loader->alias('Helper', '\\Onefasteuro\\Theme\\Helper');
     });
     /** blade partials **/
     \Blade::extend(function ($view, $compiler) {
         $pattern = $compiler->createMatcher('partials');
         return preg_replace($pattern, '$1<?php echo \\$__env->make("theme.views::".Helper::skin().".partials.".$2, array_except(get_defined_vars(), array("__data", "__path")))->render(); ?>', $view);
     });
 }
开发者ID:onefasteuro,项目名称:theme,代码行数:30,代码来源:ThemeServiceProvider.php


示例10: bladeDirectives

 /**
  * Register the blade directives
  *
  * @return void
  */
 private function bladeDirectives()
 {
     if (!class_exists('\\Blade')) {
         return;
     }
     // Call to Entrust::hasRole
     \Blade::directive('role', function ($expression) {
         return "<?php if (\\Entrust::hasRole{$expression}) : ?>";
     });
     \Blade::directive('endrole', function ($expression) {
         return "<?php endif; // Entrust::hasRole ?>";
     });
     // Call to Entrust::can
     \Blade::directive('permission', function ($expression) {
         return "<?php if (\\Entrust::can{$expression}) : ?>";
     });
     \Blade::directive('endpermission', function ($expression) {
         return "<?php endif; // Entrust::can ?>";
     });
     // Call to Entrust::ability
     \Blade::directive('ability', function ($expression) {
         return "<?php if (\\Entrust::ability{$expression}) : ?>";
     });
     \Blade::directive('endability', function ($expression) {
         return "<?php endif; // Entrust::ability ?>";
     });
 }
开发者ID:ponylux,项目名称:entrust,代码行数:32,代码来源:EntrustServiceProvider.php


示例11: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     app()->booted(function () {
         if (!defined('LARAVEL_BOOTED')) {
             define('LARAVEL_BOOTED', microtime(true));
         }
     });
     // \View::composer('*', function($view)
     // {
     //     // prifile views?
     // });
     \Blade::directive('li', function ($args) {
         $args = explode(',', str_replace(["(", ")"], '', $args));
         $cmd = str_replace(["'", '"'], '', $args[0]);
         array_shift($args);
         $args = implode(',', $args);
         return "<?php li()->{$cmd}({$args}); ?>";
     });
     if (\DB::connection()->getDatabaseName()) {
         \DB::listen(function ($sql) {
             \Lsrur\Inspector\Facade\Inspector::addSql($sql);
         });
     }
     if (is_dir(base_path() . '/resources/views/packages/lsrur/inspector')) {
         $this->loadViewsFrom(base_path() . '/resources/views/packages/lsrur/inspector', 'inspector');
     } else {
         // The package views have not been published. Use the defaults.
         $this->loadViewsFrom(__DIR__ . '/views', 'inspector');
     }
     $kernel = $this->app->make('Illuminate\\Contracts\\Http\\Kernel');
     $kernel->pushMiddleware('Lsrur\\Inspector\\Middleware\\Inspector');
     $this->publishes([__DIR__ . '/config/inspector.php' => config_path('inspector.php')], 'config');
     $this->mergeConfigFrom(__DIR__ . '/config/inspector.php', 'inspector');
 }
开发者ID:lsrur,项目名称:inspector,代码行数:39,代码来源:InspectorServiceProvider.php


示例12: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     /* @eval($var++) */
     \Blade::extend(function ($view) {
         return preg_replace('/\\@eval\\((.+)\\)/', '<?php ${1}; ?>', $view);
     });
 }
开发者ID:codex-project,项目名称:develop,代码行数:12,代码来源:AppServiceProvider.php


示例13: register

 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->bind('Illuminate\\Contracts\\Auth\\Registrar', 'App\\Services\\Registrar');
     \Blade::setRawTags('{{', '}}');
     \Blade::setContentTags('{{{', '}}}');
     \Blade::setEscapedContentTags('{{{', '}}}');
 }
开发者ID:bayudarmantra,项目名称:collaborative,代码行数:12,代码来源:AppServiceProvider.php


示例14: boot

 public function boot()
 {
     //@define $i = 'whatever'
     \Blade::extend(function ($value) {
         return preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $value);
     });
 }
开发者ID:Synthx,项目名称:Acamar,代码行数:7,代码来源:BladeServiceProvider.php


示例15: index

 /**
  * Return template for Angular
  *
  * @return View
  */
 public function index()
 {
     // Change blade tags so they don't clash with Angular
     Blade::setEscapedContentTags('[[[', ']]]');
     Blade::setContentTags('[[', ']]');
     return View::make('addressbook');
 }
开发者ID:lakedawson,项目名称:vocal,代码行数:12,代码来源:UserController.php


示例16: registerBladeTemplate

 /**
  * Register the view environment.
  */
 public function registerBladeTemplate()
 {
     /*
     |--------------------------------------------------------------------------
     | @lm-attrs
     |--------------------------------------------------------------------------
     |
     | Buffers the output if there's any.
     | The output will be passed to mergeStatic()
     | where it is merged with item's attributes
     |
     */
     \Blade::extend(function ($view, $compiler) {
         $pattern = '/(\\s*)@lm-attrs\\s*\\((\\$[^)]+)\\)/';
         return preg_replace($pattern, '$1<?php $lm_attrs = $2->attr(); ob_start(); ?>', $view);
     });
     /*
     |--------------------------------------------------------------------------
     | @lm-endattrs
     |--------------------------------------------------------------------------
     |
     | Reads the buffer data using ob_get_clean()
     | and passes it to MergeStatic().
     | mergeStatic() takes the static string,
     | converts it into a normal array and merges it with others.
     |
     */
     \Blade::extend(function ($view, $compiler) {
         $pattern = $compiler->CreatePlainMatcher('lm-endattrs');
         return preg_replace($pattern, '$1<?php echo \\Lavary\\Menu\\Builder::mergeStatic(ob_get_clean(), $lm_attrs); ?>$2', $view);
     });
 }
开发者ID:sunel,项目名称:laravel-layout,代码行数:35,代码来源:LavaryMenuServiceProvider.php


示例17: registerPHP

 /**
  * register `@php()` directive
  */
 public static function registerPHP($tagName = 'php')
 {
     \Blade::extend(function ($view, $compiler) use($tagName) {
         $pattern = $compiler->createMatcher($tagName);
         $code = "<?php \$2 ?" . ">";
         return preg_replace($pattern, $code, $view);
     });
 }
开发者ID:grohiro,项目名称:laravel-blade-macro,代码行数:11,代码来源:Macro.php


示例18: boot

 /**
  * 引导任何应用服务。
  *
  * @return void
  */
 public function boot()
 {
     \Blade::extend(function ($view, $compiler) {
         $this->app->make('phpBlade')->php($view, $compiler);
         $this->app->make('phpBlade')->endphp($view, $compiler);
         $this->app->make('phpBlade')->datetime($view, $compiler);
         return $view;
     });
 }
开发者ID:shsrain,项目名称:SimpleCms,代码行数:14,代码来源:BladeServiceProvider.php


示例19: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     parent::boot();
     \Blade::setRawTags("[[", "]]");
     \Blade::setContentTags('<%', '%>');
     // for variables and all things Blade
     \Blade::setEscapedContentTags('<%%', '%%>');
     // for escaped data
 }
开发者ID:jtpenny,项目名称:laratasks,代码行数:14,代码来源:AppServiceProvider.php


示例20: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     \Blade::directive('combine', function ($expr) {
         return \Blade::compileString("implode(' ', with{$expr})");
     });
     \Blade::directive('capitalize', function ($expr) {
         return \Blade::compileString("ucfirst(with{$expr})");
     });
 }
开发者ID:jairovsky,项目名称:laravel-nested-directive-example,代码行数:14,代码来源:AppServiceProvider.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Block类代码示例发布时间:2022-05-23
下一篇:
PHP BizSystem类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap