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