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


PHP View::getPartial方法代码示例

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


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

示例1: getRender

 /**
  * {@inheritdoc}
  */
 public function getRender($template = null, array $params = [])
 {
     $this->isInitialized || $this->initialize();
     if (empty($template)) {
         $className = (new \ReflectionObject($this))->getShortName();
         $template = mb_strtolower($className);
     }
     $view = new View();
     $view->setDI($this->getDI());
     $view->setViewsDir($this->getViewPath());
     return $view->getPartial($template, array_merge($this->getViewParams(), $params));
 }
开发者ID:vegas-cmf,项目名称:mvc,代码行数:15,代码来源:ComponentAbstract.php

示例2: testPartials

 public function testPartials()
 {
     $view = new View();
     $view->setBasePath(__DIR__ . '/../');
     $view->setViewsDir('unit-tests/views/');
     $view->setParamToView('cool_var', 'le-this');
     // Single partial
     $view->start();
     $view->render('test5', 'index');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>Hey, this is a partial, also le-this</html>' . PHP_EOL);
     // Multiple partials
     $view->start();
     $view->render('test9', 'index');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>Hey, this is a partial, also le-this<br />Hey, this is a second partial, also le-this</html>' . PHP_EOL);
     // A partial within other partial
     $view->start();
     $view->render('test5', 'subpartial');
     $view->finish();
     $this->assertEquals('<html>Including Hey, this is a partial, also le-this</html>' . PHP_EOL, $view->getContent());
     // Single partial in overridden main view
     $view->setMainView('html5');
     $view->start();
     $view->render('test5', 'index');
     $view->finish();
     $this->assertEquals('<!DOCTYPE html><html>Hey, this is a partial, also le-this</html>' . PHP_EOL, $view->getContent());
     // Retrieve a partial as a string
     $this->assertEquals('Hey, this is a partial, also le-this', $view->getPartial('partials/_partial1', array('cool_var' => 'le-this')));
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:30,代码来源:ViewTest.php

示例3: testRenderingWithPartials

 /**
  * Tests rendering with partials
  *
  * @author Andres Gutierrez <andres@phalconphp.com>
  * @since  2012-05-28
  */
 public function testRenderingWithPartials()
 {
     $this->specify('The rendering with partials does not work as expected', function () {
         $view = new View();
         $view->setViewsDir(PATH_DATA . 'views' . DIRECTORY_SEPARATOR);
         $view->setParamToView('cool_var', 'le-this');
         $view->start();
         $view->render('test5', 'index');
         $view->finish();
         expect($view->getContent())->equals("<html>Hey, this is a partial, also le-this</html>\n");
         $view->start();
         $view->render('test9', 'index');
         $view->finish();
         expect($view->getContent())->equals("<html>Hey, this is a partial, also le-this<br />Hey, this is a second partial, also le-this</html>\n");
         $view->start();
         $view->render('test5', 'subpartial');
         $view->finish();
         expect($view->getContent())->equals("<html>Including Hey, this is a partial, also le-this</html>\n");
         $view->setMainView('html5');
         $view->start();
         $view->render('test5', 'index');
         $view->finish();
         expect($view->getContent())->equals("<!DOCTYPE html><html>Hey, this is a partial, also le-this</html>\n");
         expect($view->getPartial('partials/_partial1', ['cool_var' => 'le-this']))->equals('Hey, this is a partial, also le-this');
     });
 }
开发者ID:phalcon,项目名称:cphalcon,代码行数:32,代码来源:ViewTest.php


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