Bläddra i källkod

Fixed passing partials to already-instantiated Mustache object. Added (brief) documentation for partials.

Justin Hileman 15 år sedan
förälder
incheckning
bbebabe39a
1 ändrade filer med 7 tillägg och 3 borttagningar
  1. 7 3
      Mustache.php

+ 7 - 3
Mustache.php

@@ -25,11 +25,13 @@ class Mustache {
 	/**
 	 * 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
 	 * @param mixed $template (default: null)
 	 * @param mixed $view (default: null)
+	 * @param mixed $partials (default: null)
 	 * @return void
 	 */
 	public function __construct($template = null, $view = null, $partials = null) {
@@ -42,16 +44,18 @@ class Mustache {
 	 * Render the given template and view object.
 	 *
 	 * 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
 	 * @param string $template (default: null)
 	 * @param mixed $view (default: null)
+	 * @param mixed $partials (default: null)
 	 * @return string Rendered Mustache template.
 	 */
 	public function render($template = null, $view = null, $partials = null) {
 		if ($template === null) $template = $this->template;
 		if ($view === null)     $view = $this->view;
-		if ($partials === null) $partials = $this->partials;
+		if ($partials !== null) $this->partials = $partials;
 
 		$template = $this->renderSection($template, $view);
 		return $this->renderTags($template, $view);