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

PHP Plates\Engine类代码示例

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

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



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


示例16: register

 public function register(App $glue)
 {
     $glue->singleton('League\\Plates\\Engine', function ($glue) {
         if (!$glue->config->exists('plates.path')) {
             // We need a default template folder
             throw new \Exception("You must configure the plates.path");
         }
         $engine = new Engine($glue->config->get('plates.path'));
         // Register some extensions
         $engine->loadExtension($glue->make('Glue\\Plates\\Extensions\\UrlHelpers'));
         return $engine;
     });
     $glue->alias('League\\Plates\\Engine', 'plates');
 }
开发者ID:gluephp,项目名称:glue-plates,代码行数:14,代码来源:ServiceProvider.php


示例17: getInstance

 /**
  * Get a Plates engine
  *
  * @return \League\Plates\Engine
  */
 public function getInstance()
 {
     if (!$this->engineInstance) {
         // Create new Plates engine
         $this->engineInstance = new \League\Plates\Engine($this->templatesPath ?: $this->getTemplatesDirectory());
         if ($this->fileExtension) {
             $this->engineInstance->setFileExtension($this->fileExtension);
         }
         if (count($this->templatesFolders)) {
             foreach ($this->templatesFolders as $name => $path) {
                 $this->engineInstance->addFolder($name, $path);
             }
         }
     }
     return $this->engineInstance;
 }
开发者ID:philipsharp,项目名称:slim-view-plates,代码行数:21,代码来源:Plates.php


示例18: getInstance

 /**
  * Get an instance of the Plates Engine
  *
  * @return \League\Plates\Engine
  */
 public function getInstance()
 {
     if (!$this->engineInstance) {
         $this->engineInstance = new Engine($this->templatesPath ?: $this->getTemplatesDirectory());
         if ($this->fileExtension) {
             $this->engineInstance->setFileExtension($this->fileExtension);
         }
         if (count($this->templatesFolders) > 0) {
             foreach ($this->templatesFolders as $name => $path) {
                 $this->engineInstance->addFolder($name, $path);
             }
         }
         if (count($this->parserExtensions) > 0) {
             foreach ($this->parserExtensions as $extension) {
                 $this->engineInstance->loadExtension($extension);
             }
         }
     }
     return $this->engineInstance;
 }
开发者ID:media32,项目名称:slim-view-plates,代码行数:25,代码来源:Plates.php


示例19: getLoader

 /**
  * Plates paths loader.
  */
 protected function getLoader() : LeagueEngine
 {
     if (!$this->engine) {
         $config = $this->config;
         $this->engine = new LeagueEngine($config['template']['default'] ?? null, $config['engine']['plates']['file_extension'] ?? null);
         if (($paths = $config['template']['paths'] ?? null) !== null) {
             foreach ($paths as $name => $addPaths) {
                 $this->engine->addFolder($name, $addPaths);
             }
         }
     }
     return $this->engine;
 }
开发者ID:narrowspark,项目名称:framework,代码行数:16,代码来源:Plates.php


示例20: parse

 /**
  * Parse name to determine template folder and filename.
  */
 protected function parse()
 {
     $parts = explode('::', $this->name);
     if (count($parts) === 1) {
         if (is_null($this->engine->getDirectory())) {
             $this->throwParseException('The default directory has not been defined.');
         }
         if ($parts[0] === '') {
             $this->throwParseException('The template name cannot be empty.');
         }
         $this->file = $parts[0];
     } elseif (count($parts) === 2) {
         if ($parts[0] === '') {
             $this->throwParseException('The folder name cannot be empty.');
         }
         if ($parts[1] === '') {
             $this->throwParseException('The template name cannot be empty.');
         }
         if (!$this->engine->getFolders()->exists($parts[0])) {
             $this->throwParseException('The folder "' . $parts[0] . '" does not exist.');
         }
         $this->folder = $this->engine->getFolders()->get($parts[0]);
         $this->file = $parts[1];
     } else {
         $this->throwParseException('Do not use the folder namespace seperator "::" more than once.');
     }
 }
开发者ID:joelouisworthington,项目名称:odesandink,代码行数:30,代码来源:Name.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Request\Init类代码示例发布时间:2022-05-23
下一篇:
PHP Entity\AccessTokenEntity类代码示例发布时间: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