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


PHP Engine::render方法代码示例

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


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

示例1: __invoke

 /**
  * Handler.
  * 
  * @param ServerRequestInterface $request
  * @param ResponseInterface      $response
  * 
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     $page = $request->getAttribute('page', '/index');
     $content = $this->contentLoader->getContent($page);
     $template = $content->getMetadataEntry('template');
     $params = array_merge($content->getMetadata(), ['html' => $content->getHtml()]);
     $response->getBody()->write($this->plates->render($template, $params));
     return $response->withHeader('Content-Type', 'text/html');
 }
开发者ID:AndrewCarterUK,项目名称:php-berkshire-website,代码行数:17,代码来源:PageAction.php

示例2: __invoke

 /**
  * @param $template
  * @return bool
  */
 public function __invoke($template)
 {
     //
     $template = $this->getPlatesPath($template);
     // get the HTML for whatever is going on
     echo $this->engine->render($template);
     // because we echo'd already, we return false so it's not double-echo'd by wordpress'
     // default `include $template` statement
     return false;
 }
开发者ID:kkeiper1103,项目名称:plates-for-wordpress,代码行数:14,代码来源:TemplateIncludeFilter.php

示例3: index

 /**
  * @param BatchManager           $batches
  * @param ServerRequestInterface $request
  * @param string                 $task
  *
  * @return View
  */
 public function index(BatchManager $batches, ServerRequestInterface $request, $task = 'custom')
 {
     // Interactive mode
     $query = $request->getQueryParams();
     if (array_key_exists('interactive', $query)) {
         $this->configuration['tasks'] = $query['interactive'];
     }
     $task = $this->getTask($task);
     $sync = array_get($query, 'sync');
     $method = $sync ? 'runTask' : 'getCommandsFrom';
     $commands = $this->runner->{$method}($task);
     // Store commands for retrieval
     $hash = $batches->set($commands);
     return $this->views->render('index', ['tasks' => $commands, 'hash' => $hash, 'url' => $this->configuration->get('url')]);
 }
开发者ID:anahkiasen,项目名称:sadness-deployer,代码行数:22,代码来源:DeployController.php

示例4: __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

示例5: render

 /**
  * Render the template.
  *
  * @param string   $name
  * @param string[] $data
  *
  * @throws \LogicException
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function render($name, array $data = [])
 {
     if (!isset($this->response)) {
         throw new \LogicException(sprintf('Invalid %s object instance', ResponseInterface::class));
     }
     return $this->response->write($this->plates->render($name, $data));
 }
开发者ID:projek-xyz,项目名称:slim-plates,代码行数:17,代码来源:Plates.php

示例6: render

 /**
  * Render a string
  *
  * @param string $template The template content to render
  * @param array $locals The variable to use in template
  * @return null|string
  */
 public function render($template, array $locals = array())
 {
     $tmpName = uniqid('plates_tmp_', false);
     $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tmpName;
     if (!is_null($this->plates->getFileExtension())) {
         $tmpPath .= '.' . $this->plates->getFileExtension();
     }
     $isTmpRegister = $this->plates->getFolders()->exists(sys_get_temp_dir());
     if (!$isTmpRegister) {
         $this->plates->addFolder(sys_get_temp_dir(), sys_get_temp_dir());
     }
     file_put_contents($tmpPath, $template);
     $data = $this->plates->render(sys_get_temp_dir() . '::' . $tmpName, $locals);
     unlink($tmpPath);
     if (!$isTmpRegister) {
         $this->plates->getFolders()->remove(sys_get_temp_dir());
     }
     return $data;
 }
开发者ID:phptransformers,项目名称:plates,代码行数:26,代码来源:PlatesTransformer.php

示例7: render

 public function render($name, $data = [], $echo = false)
 {
     $data["layoutName"] = $this->getLayoutName();
     $data["crud"] = $this;
     $html = $this->template->render($name, $data);
     if ($echo) {
         echo $html;
     }
     return $html;
 }
开发者ID:louislam,项目名称:louislam-crud,代码行数:10,代码来源:LouisCRUD.php

示例8: render

 protected function render($name)
 {
     if (!count($this->templateVars)) {
         return $this->templater->render($name);
     }
     $vars = [];
     foreach ($this->templateVars as $var) {
         $vars = array_merge($vars, $var);
     }
     return $this->templater->render($name, $vars);
 }
开发者ID:JordanRL,项目名称:eden,代码行数:11,代码来源:AbstractController.php

示例9: 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

示例10: __invoke

 public function __invoke(array $input)
 {
     $name = 'world';
     if (!empty($input['name'])) {
         $name = $input['name'];
     }
     ////////////////////
     $application = new Application();
     $application_data = $application->is_pjax();
     //print_r( '<pre>' );
     // print_r( $application_data );
     //print_r( '</pre>');
     ////////////////////
     // simple
     // Create new Plates instance
     //		$plates = new Engine(APPPATH.'templates');
     // Render a template
     // $template = $plates->render('partials/profile', ['name' => $name . ' | ' . $data_from_an_other_class]);
     //		$template = $plates->render('partials/profile', ['name' => $name . ' | ' . $application_data]);
     $data = ['friends' => ['mikka', 'makka', 'zorro']];
     //			$friends = [
     //			  ['name', 'zorro'],
     //			];
     ////////////////////
     // using folders
     // Create new Plates instance
     $plates = new Engine(APPPATH . 'templates');
     // Register a Plates extension
     $plates->loadExtension(new Utils());
     // Add folders
     $plates->addFolder('layout', APPPATH . 'templates');
     $plates->addFolder('partials', APPPATH . 'templates/partials');
     $plates->addFolder('static', APPPATH . 'templates/static');
     // assign data to plates
     $plates->addData($data, 'layout');
     // Render
     $template = $plates->render('partials::profile', ['name' => $name]);
     ////////////////////
     $invitation = 'I invite you';
     // return
     return (new Payload())->withStatus(Payload::OK)->withOutput(['hello' => $template, 'invitation' => $invitation]);
 }
开发者ID:elevenone,项目名称:spark-project-foundation,代码行数:42,代码来源:Index.php

示例11: testRender

 public function testRender()
 {
     $this->assertSame($this->engine->render('simple'), $this->strategy->render('simple'));
 }
开发者ID:tonis-io,项目名称:tonis,代码行数:4,代码来源:PlatesStrategyTest.php

示例12: insert

 /**
  * Output a rendered template.
  * @param  string $name
  * @param  array  $data
  * @return null
  */
 protected function insert($name, array $data = array())
 {
     echo $this->engine->render($name, $data);
 }
开发者ID:joelouisworthington,项目名称:odesandink,代码行数:10,代码来源:Template.php

示例13: render

 /**
  * @param PayloadInterface $payload
  *
  * @return string
  */
 private function render(PayloadInterface $payload)
 {
     $template = $payload->getSetting('template');
     $output = $payload->getOutput();
     return $this->engine->render($template, $output);
 }
开发者ID:equip,项目名称:framework,代码行数:11,代码来源:PlatesFormatter.php

示例14: render

 /**
  * Render a plate template and return with a PSR-7 Response object.
  *
  * @param ResponseInterface $response
  * @param $template
  * @param array $data
  *
  * @return ResponseInterface
  */
 public function render(ResponseInterface $response, $template, array $data = [])
 {
     $response->getBody()->write($this->engine->render($template, $data));
     return $response;
 }
开发者ID:carbontwelve,项目名称:slim-plates,代码行数:14,代码来源:PlatesRenderer.php

示例15: evaluate

 /**
  * Evaluates the template with its variables.
  *
  * @param string $template The template relative path
  * @param array  $vars     The template variables
  *
  * @return string
  */
 public function evaluate($template, array $vars = [])
 {
     $reference = $this->loadTemplate($template, $vars);
     return $this->plates->render($template, $reference->getVariables());
 }
开发者ID:Symfomany,项目名称:laravelcinema,代码行数:13,代码来源:PlatesEngineAdapter.php


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