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


PHP BladeCompiler::compileString方法代码示例

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


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

示例1: testStatements

 public function testStatements()
 {
     $this->bladedManager->expects($this->any())->method('getCommand')->will($this->returnValue($this));
     $this->appMock->expects($this->any())->method('make')->will($this->returnCallback(function ($resolvable) {
         switch ($resolvable) {
             case 'view':
                 return $this->viewMock;
             case 'laravel-commode.bladed':
                 return $this->bladedManager;
             case BladedServiceProvider::PROVIDES_STRING_COMPILER:
                 return $this->stringCompiler;
             default:
                 var_dump($resolvable, 'in testStatements');
                 die;
         }
     }));
     foreach (['condition', 'statement', 'templates'] as $file) {
         $this->assertSame(bl_get_contents('templates/results' . ucfirst($file)), $this->bladeCompiler->compileString(bl_get_contents("templates/{$file}.blade._php")));
     }
     $expect = bl_get_contents('templates/resultsIterators');
     $compiled = $this->bladeCompiler->compileString(bl_get_contents("templates/iterators.blade._php"));
     preg_match_all('/(\\$count[\\d\\w]{1,})/is', $compiled, $countVars);
     $countVars = array_values($countVars[0]);
     preg_match_all('/(\\$key[\\d\\w]{1,})/is', $compiled, $keyVars);
     $keyVars = array_values($keyVars[0]);
     $countIteration = 0;
     $keyIteration = 0;
     $expect = preg_replace_callback('/\\{\\{countVar\\}\\}/is', function ($match) use($countVars, &$countIteration) {
         return $countVars[$countIteration++];
     }, $expect);
     $expect = preg_replace_callback('/\\{\\{\\$key\\}\\}/is', function ($match) use($keyVars, &$keyIteration) {
         return $keyVars[$keyIteration++];
     }, $expect);
     $this->assertSame($expect, $compiled);
 }
开发者ID:laravel-commode,项目名称:bladed,代码行数:35,代码来源:BladedCompilerTest.php

示例2: render

 /**
  * Get the evaluated contents of the file.
  */
 public function render()
 {
     $viewContent = $this->buildBladeViewContent();
     if ($this->isExpired()) {
         $this->filesystem->put($this->cached, $this->bladeCompiler->compileString($viewContent));
     }
     $data = $this->getViewData();
     return $this->engine->get($this->cached, $data);
 }
开发者ID:themsaid,项目名称:katana-core,代码行数:12,代码来源:MarkdownFileBuilder.php

示例3: render

 /**
  * render
  *
  * @param       $string
  * @param array $vars
  * @return string
  */
 public function render($string, array $vars = array())
 {
     $this->files->put($this->tmpFilePath, $this->compiler->compileString($string));
     if (is_array($vars) && !empty($vars)) {
         extract($vars);
     }
     ob_start();
     include $this->tmpFilePath;
     $var = ob_get_contents();
     ob_end_clean();
     $this->files->delete($this->tmpFilePath);
     return $var;
 }
开发者ID:marianvlad,项目名称:blade-extensions,代码行数:20,代码来源:BladeStringRenderer.php

示例4: render

 /**
  * render
  *
  * @param       $string
  * @param array $vars
  * @return string
  */
 public function render($string, array $vars = array())
 {
     $fileName = uniqid(time(), false);
     $this->generateDirectoryStructure(storage_path(), ['sebwite/stubs']);
     $path = storage_path("sebwite/stubs/{$fileName}");
     $this->files->put($path, $this->compiler->compileString($string));
     if (is_array($vars) && !empty($vars)) {
         extract($vars);
     }
     ob_start();
     include $path;
     $var = ob_get_contents();
     ob_end_clean();
     $this->files->delete($path);
     return $var;
 }
开发者ID:docit,项目名称:support,代码行数:23,代码来源:StubGenerator.php

示例5: fromString

 /**
  * {@inheritdoc}
  */
 public static function fromString($string, Translations $translations, array $options = [])
 {
     $cachePath = empty($options['cachePath']) ? sys_get_temp_dir() : $options['cachePath'];
     $bladeCompiler = new BladeCompiler(new Filesystem(), $cachePath);
     $string = $bladeCompiler->compileString($string);
     PhpCode::fromString($string, $translations, $options);
 }
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:10,代码来源:Blade.php

示例6: render

 public function render($str, array $vars = [])
 {
     $__tmp_stub_file = Str::random() . uniqid(time(), false);
     !$this->fs->exists($this->cachePath) && $this->fs->makeDirectory($this->cachePath, 0755, true);
     $__tmp_stub_path = Path::join($this->cachePath, $__tmp_stub_file);
     $this->fs->put($__tmp_stub_path, $this->compiler->compileString($str));
     $__env = $this->getViewFactory();
     if (is_array($vars) && 0 !== count($vars)) {
         extract($vars);
     }
     ob_start();
     include $__tmp_stub_path;
     $var = ob_get_contents();
     ob_end_clean();
     $this->fs->delete($__tmp_stub_path);
     return $var;
 }
开发者ID:laradic-old,项目名称:illuminate,代码行数:17,代码来源:Blade.php

示例7: compileBlade

 /**
  * Parses and compiles strings by using Blade Template System.
  *
  * @param string $str
  * @param array $data
  * @return string
  */
 public static function compileBlade($str, $data = [])
 {
     $empty_filesystem_instance = new Filesystem();
     $blade = new BladeCompiler($empty_filesystem_instance, 'datatables');
     $parsed_string = $blade->compileString($str);
     ob_start() && extract($data, EXTR_SKIP);
     eval('?>' . $parsed_string);
     $str = ob_get_contents();
     ob_end_clean();
     return $str;
 }
开发者ID:rayhan0421,项目名称:laravel-datatables,代码行数:18,代码来源:Helper.php

示例8: testCompileViews

 public function testCompileViews()
 {
     $compiler = new BladeCompiler(new Filesystem(), $this->config['storage_path']);
     $this->generator->compileViews($this->config['paths'], $this->config['storage_path']);
     foreach ($this->config['paths'] as $path) {
         $files = glob(realpath($path) . '/{,**/}*.php', GLOB_BRACE);
         foreach ($files as $file) {
             $contents = $this->generator->parseToken($this->files->get($file));
             $this->assertEquals($compiler->compileString($contents), $this->files->get($this->config['storage_path'] . "/" . md5($file) . ".php"));
         }
     }
 }
开发者ID:pauluse,项目名称:laravel-gettext,代码行数:12,代码来源:PoGeneratorTest.php

示例9: compileWiths

 /**
  * Compile blade template with passing arguments.
  *
  * @param $value
  * @param  array $args
  * @throws \Exception
  * @return string
  */
 public function compileWiths($value, array $args = array())
 {
     $generated = parent::compileString($value);
     ob_start() and extract($args, EXTR_SKIP);
     try {
         eval('?>' . $generated);
     } catch (\Exception $e) {
         ob_get_clean();
         throw $e;
     }
     $content = ob_get_clean();
     return $content;
 }
开发者ID:laravel-commode,项目名称:bladed,代码行数:21,代码来源:StringCompiler.php

示例10: getContent

 private function getContent()
 {
     $compiler = new BladeCompiler(new Filesystem(), ".");
     $template = $this->getTemplate();
     $compiled = $compiler->compileString(' ?>' . $template);
     $up = trim($this->up, "\n");
     $down = trim($this->down, "\n");
     ob_start();
     eval($compiled);
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
开发者ID:PlatiniumGroup,项目名称:DBDiff,代码行数:13,代码来源:Templater.php

示例11: compileBlade

 /**
  * Parses and compiles strings by using Blade Template System.
  *
  * @param string $str
  * @param array $data
  * @return string
  * @throws \Exception
  */
 public static function compileBlade($str, $data = [])
 {
     if (view()->exists($str)) {
         return view($str, $data)->render();
     }
     $empty_filesystem_instance = new Filesystem();
     $blade = new BladeCompiler($empty_filesystem_instance, 'datatables');
     $parsed_string = $blade->compileString($str);
     ob_start() && extract($data, EXTR_SKIP);
     try {
         eval('?>' . $parsed_string);
     } catch (\Exception $e) {
         ob_end_clean();
         throw $e;
     }
     $str = ob_get_contents();
     ob_end_clean();
     return $str;
 }
开发者ID:rxfu,项目名称:student,代码行数:27,代码来源:Helper.php

示例12: compileViews

 /**
  * Compile views.
  *
  * @param  array  $paths
  * @param  string $storagePath
  * @return $this
  */
 public function compileViews(array $paths, $storagePath)
 {
     $this->makeDestination($storagePath);
     $compiler = new BladeCompiler($this->files, $storagePath);
     foreach ($paths as $path) {
         $files = $this->files->glob(realpath($path) . '/{,**/}*.php', GLOB_BRACE);
         foreach ($files as $file) {
             if (!Str::endsWith(strtolower($file), '.blade.php')) {
                 continue;
             }
             $compiler->setPath($file);
             $contents = $this->parseToken($this->files->get($file));
             $contents = $compiler->compileString($contents);
             $compiledPath = $compiler->getCompiledPath($compiler->getPath());
             $this->files->put($compiledPath . '.php', $contents);
         }
     }
     return $this;
 }
开发者ID:pauluse,项目名称:laravel-gettext,代码行数:26,代码来源:PoGenerator.php

示例13: handle

 public function handle()
 {
     $this->info('start view compiler');
     $targetDir = storage_path(config('trans.view_store_path'));
     if (!file_exists($targetDir)) {
         $this->createDirectory($targetDir);
         $this->comment('created directory ' . $targetDir);
     }
     $path = base_path(config('trans.view_blade_path'));
     $fs = new Filesystem($path);
     $files = $fs->allFiles(realpath($path));
     $compiler = new BladeCompiler($fs, $targetDir);
     foreach ($files as $file) {
         $filePath = $file->getRealPath();
         $this->comment('compile view: ' . $filePath);
         $compiler->setPath($filePath);
         $contents = $compiler->compileString($fs->get($filePath));
         $compiledPath = $compiler->getCompiledPath($compiler->getPath());
         $fs->put($compiledPath . '.php', $contents);
     }
 }
开发者ID:gummibeer,项目名称:laravel-translation,代码行数:21,代码来源:CompileViews.php

示例14: blader

 /**
  * Parses and compiles strings by using Blade Template System
  *
  * @return string
  */
 private function blader($str, $data = array())
 {
     $empty_filesystem_instance = new Filesystem();
     $blade = new BladeCompiler($empty_filesystem_instance, 'datatables');
     $parsed_string = $blade->compileString($str);
     ob_start() and extract($data, EXTR_SKIP);
     try {
         eval('?>' . $parsed_string);
     } catch (\Exception $e) {
         ob_end_clean();
         throw $e;
     }
     $str = ob_get_contents();
     ob_end_clean();
     return $str;
 }
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:21,代码来源:Datatables.php

示例15: compile

 /**
  * Compile blade template to HTML.
  *
  * @param  string $template
  * @param  array $data
  *
  * @throws \Exception
  * @return string
  */
 public function compile($template, $data = array())
 {
     $compiler = new BladeCompiler($this->files, 'theme');
     // Get blade compiler.
     $parsed = $compiler->compileString($template);
     ob_start() and extract($data, EXTR_SKIP);
     try {
         eval('?>' . $parsed);
     } catch (\Exception $e) {
         ob_end_clean();
         throw $e;
     }
     $template = ob_get_contents();
     ob_end_clean();
     return $template;
 }
开发者ID:bokbok123,项目名称:ORS,代码行数:25,代码来源:Breadcrumb.php


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