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


PHP Plates\Engine类代码示例

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


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

示例1: __invoke

 public function __invoke(array $input)
 {
     $name = 'index';
     if (!empty($input['name'])) {
         $name = $input['name'];
     }
     //		$filename = APPPATH . 'templates/static/' . $name;
     //		if (file_exists($filename)) {
     //			echo "The file $filename does not exist";
     //			die('the file does not exist');
     //		}
     // Create new Plates instance
     $plates = new Engine(APPPATH . 'templates');
     // Register extension
     $plates->loadExtension(new Utils());
     // Check static page or partial exists
     if ($plates->exists('static/' . $name)) {
         // Render a template
         $template = $plates->render('static/' . $name);
     } else {
         header("HTTP/1.0 404 Not Found");
         echo "PHP continues.\n";
         echo "Not after a die, however.\n";
         die;
     }
     // return
     return (new Payload())->withStatus(Payload::OK)->withOutput(['hello' => $template]);
 }
开发者ID:elevenone,项目名称:spark-project-foundation,代码行数:28,代码来源:StaticPage.php

示例2: setUp

 protected function setUp()
 {
     $plates = new Engine(__DIR__ . '/Resources/views');
     $plates->setFileExtension(null);
     $plates->addData(['foo' => 'bar']);
     $this->engine = new PlatesEngineAdapter($plates);
 }
开发者ID:Symfomany,项目名称:laravelcinema,代码行数:7,代码来源:PlatesEngineAdapterTest.php

示例3: register

 /**
  * {@inheritDoc}
  */
 public function register()
 {
     $container = $this->getContainer();
     // route map which contains routes for lookup
     $container->singleton(Router\RouteMap::class, function () {
         return new Router\RouteMap();
     });
     // handles errors in the life-cycle
     $container->singleton(Handler\ErrorInterface::class, function () {
         return new Handler\Error();
     });
     // handles not found errors in the life-cycle
     $container->singleton(Handler\NotFoundInterface::class, function () {
         return new Handler\NotFound();
     });
     // plates engine
     $container->singleton(Engine::class, function () use($container) {
         $engine = new Engine(__DIR__ . '/../view');
         $engine->registerFunction('url', new View\Plates\UrlFunction($container->get(Router\RouteMap::class)));
         return $engine;
     });
     // view manager
     $container->singleton(View\Manager::class, function () use($container) {
         return new View\Manager(new View\PlatesStrategy($container->get(Engine::class)));
     });
     // router
     $container->add(Router\Router::class, function () use($container) {
         return new Router\Router($container->get(Router\RouteMap::class));
     });
 }
开发者ID:ezimuel,项目名称:tonis,代码行数:33,代码来源:ServiceProvider.php

示例4: register

 /**
  * Register extension functions.
  * @return null
  */
 public function register(Engine $engine)
 {
     $engine->registerFunction('fh_default_val', array($this, 'fhDefaultVal'));
     $engine->registerFunction('fh_input_select', array($this, 'fhInputSelect'));
     $engine->registerFunction('fh_error_css_class', array($this, 'fhErrorCssClass'));
     $engine->registerFunction('fh_show_errors', array($this, 'fhShowErrors'));
 }
开发者ID:hidayat365,项目名称:phpindonesia.or.id-membership2,代码行数:11,代码来源:PlatesFormHelperExtension.php

示例5: __construct

 /**
  * PlatesProvider constructor.
  * @param Engine $plates
  * @param string $root_path
  * @param string $namespace
  */
 public function __construct(Engine $plates, $root_path, $namespace)
 {
     $this->plates = $plates;
     $this->namespace = $namespace;
     if (!$plates->getFolders()->exists($namespace)) {
         $plates->addFolder($namespace, $root_path);
     }
 }
开发者ID:perfumer,项目名称:framework,代码行数:14,代码来源:PlatesProvider.php

示例6: register

 /**
  * @param  Engine $engine
  */
 public function register(Engine $engine)
 {
     // Load the built in URI extension
     $engine->loadExtension(new URI($this->request->getPathInfo()));
     // Custom methods
     $engine->registerFunction('route', [$this, 'route']);
     $engine->registerFunction('asset', [$this, 'asset']);
 }
开发者ID:gluephp,项目名称:glue-plates,代码行数:11,代码来源:UrlHelpers.php

示例7: plates

 private function plates()
 {
     $league = new Plates\Engine(APP . 'views');
     $league->setFileExtension('tpl');
     $league->loadExtension(new Plates\Extension\URI(trim(strtok(str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['REQUEST_URI']), '?'), '/')));
     $league->loadExtension(new MY\Plates\Extension());
     return $league;
 }
开发者ID:jezqhiel,项目名称:cms-packages,代码行数:8,代码来源:Controller.php

示例8: prepareEngine

 public function prepareEngine(Engine $engine)
 {
     // set file extension
     // $engine->setFileExtension('php');
     // Add folders
     $engine->addFolder('templates', APPPATH . 'templates');
     $engine->addFolder('partials', APPPATH . 'templates/partials');
     $engine->addFolder('staticpages', APPPATH . 'templates/staticpages');
 }
开发者ID:elevenone,项目名称:sparkle,代码行数:9,代码来源:PlatesConfiguration.php

示例9: __invoke

 public function __invoke(array $config)
 {
     $theme = $config['theme'];
     $templateEngine = new Engine();
     $templateEngine->addFolder('app', 'templates');
     $templateEngine->addFolder('theme', 'public/themes/' . $theme . '/templates');
     $templateEngine->setFileExtension('phtml');
     $templateEngine->loadExtensions([new AssetExt('public', true), new ThemeAssetExt('themes/' . $theme . '/assets')]);
     return new Application($config, new PlatesTemplateRenderer($templateEngine));
 }
开发者ID:nikolaposa,项目名称:devpage,代码行数:10,代码来源:ApplicationFactory.php

示例10: getInstance

 public function getInstance()
 {
     if (!$this->_engineInstance) {
         // Create new Plates engine
         $this->_engineInstance = new PlatesEngine($this->getTemplatesDirectory());
         if ($this->fileExtension) {
             $this->_engineInstance->setFileExtension($this->fileExtension);
         }
     }
     return $this->_engineInstance;
 }
开发者ID:jmrunkle,项目名称:ifitfitsifitbits,代码行数:11,代码来源:PlatesView.php

示例11: __construct

 public function __construct()
 {
     $this->setUrl(env('APP_URL'));
     $this->pipe(Middleware::formatNegotiator());
     $this->pipe(Middleware::whoops());
     $this->source(new StaticFiles('build/**/*'))->build(false);
     $this->source(new StaticFiles('source/img/**/*', '/img/**/*'));
     $plates = new Engine('source/templates');
     $plates->addData(['app' => $this]);
     $this->source(new YamlFiles('source/data/*.yml'))->templates($plates);
 }
开发者ID:oscarotero,项目名称:static-boilerplate,代码行数:11,代码来源:Site.php

示例12: render

 /**
  * @param string $type
  * @return string
  */
 public function render($type = null)
 {
     $templates = new Engine($this->viewPath);
     if ($type === null) {
         if ($this->media === false) {
             $type = 'media';
         } else {
             $type = 'thumbnail';
         }
     }
     return $templates->render($type, $this->toArray());
 }
开发者ID:jclyons52,项目名称:page-preview,代码行数:16,代码来源:Preview.php

示例13: create

 /**
  * Create instance
  *
  * @return Engine
  */
 public function create(Request $request)
 {
     $engine = new Engine($this->options['view_path'], null);
     // Add folder shortcut (assets::file.js)
     $engine->addFolder('assets', $this->options['assets_path']);
     $engine->addFolder('view', $this->options['view_path']);
     $session = $request->getAttribute(SessionMiddleware::ATTRIBUTE);
     $baseUrl = $request->getAttribute('base_url');
     // Register Asset extension
     $cacheOptions = array('cachepath' => $this->options['cache_path'], 'cachekey' => $session->get('user.locale'), 'baseurl' => $baseUrl, 'minify' => $this->options['minify']);
     $engine->loadExtension(new \Odan\Plates\Extension\AssetCache($cacheOptions));
     return $engine;
 }
开发者ID:odan,项目名称:psr7-full-stack,代码行数:18,代码来源:PlatesMiddleware.php

示例14: register

 public function register(Fol $app)
 {
     $app['templates'] = function ($app) {
         $root = dirname(dirname(__DIR__));
         $templates = new Engine($root . '/templates');
         $icons = new Collection(new MaterialDesignIcons($root . '/assets/icons'));
         $templates->addData(['app' => $app]);
         $templates->registerFunction('icon', function ($name) use($icons) {
             return $icons->get($name);
         });
         return $templates;
     };
 }
开发者ID:oscarotero,项目名称:folk,代码行数:13,代码来源:Templates.php

示例15: getTemplates

 protected function getTemplates()
 {
     if (!self::$templates) {
         // Create new Plates engine
         self::$templates = new Engine(__DIR__ . '/../../views', 'tpl');
         self::$templates->registerFunction('substr', function ($string, $start, $length) {
             return substr($string, $start, $length);
         });
         self::$templates->registerFunction('cleanWikiSyntax', function ($string) {
             return preg_replace("/\\[(wiki|url)\\=(?P<url>https?:\\/\\/[^\\]]*)\\](?P<text>[^\\[]*)\\[\\/(wiki|url)\\]/i", "\$3", $string);
         });
     }
     return self::$templates;
 }
开发者ID:kl4n4,项目名称:statusboard-widgets,代码行数:14,代码来源:HtmlDataFormatter.php


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