當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Blade類代碼示例

本文整理匯總了PHP中Blade的典型用法代碼示例。如果您正苦於以下問題:PHP Blade類的具體用法?PHP Blade怎麽用?PHP Blade使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Blade類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的Blade類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。