|
@@ -25,11 +25,13 @@ class Mustache {
|
|
|
/**
|
|
/**
|
|
|
* Mustache class constructor.
|
|
* Mustache class constructor.
|
|
|
*
|
|
*
|
|
|
- * This method accepts a $template string and a $view object.
|
|
|
|
|
|
|
+ * This method accepts a $template string and a $view object. Optionally, pass an associative
|
|
|
|
|
+ * array of partials as well.
|
|
|
*
|
|
*
|
|
|
* @access public
|
|
* @access public
|
|
|
* @param mixed $template (default: null)
|
|
* @param mixed $template (default: null)
|
|
|
* @param mixed $view (default: null)
|
|
* @param mixed $view (default: null)
|
|
|
|
|
+ * @param mixed $partials (default: null)
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
public function __construct($template = null, $view = null, $partials = null) {
|
|
public function __construct($template = null, $view = null, $partials = null) {
|
|
@@ -42,16 +44,18 @@ class Mustache {
|
|
|
* Render the given template and view object.
|
|
* Render the given template and view object.
|
|
|
*
|
|
*
|
|
|
* Defaults to the template and view passed to the class constructor unless a new one is provided.
|
|
* Defaults to the template and view passed to the class constructor unless a new one is provided.
|
|
|
- *
|
|
|
|
|
|
|
+ * Optionally, pass an associative array of partials as well.
|
|
|
|
|
+ *
|
|
|
* @access public
|
|
* @access public
|
|
|
* @param string $template (default: null)
|
|
* @param string $template (default: null)
|
|
|
* @param mixed $view (default: null)
|
|
* @param mixed $view (default: null)
|
|
|
|
|
+ * @param mixed $partials (default: null)
|
|
|
* @return string Rendered Mustache template.
|
|
* @return string Rendered Mustache template.
|
|
|
*/
|
|
*/
|
|
|
public function render($template = null, $view = null, $partials = null) {
|
|
public function render($template = null, $view = null, $partials = null) {
|
|
|
if ($template === null) $template = $this->template;
|
|
if ($template === null) $template = $this->template;
|
|
|
if ($view === null) $view = $this->view;
|
|
if ($view === null) $view = $this->view;
|
|
|
- if ($partials === null) $partials = $this->partials;
|
|
|
|
|
|
|
+ if ($partials !== null) $this->partials = $partials;
|
|
|
|
|
|
|
|
$template = $this->renderSection($template, $view);
|
|
$template = $this->renderSection($template, $view);
|
|
|
return $this->renderTags($template, $view);
|
|
return $this->renderTags($template, $view);
|