當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。