Sfoglia il codice sorgente

Updated default character escaping for UTF-8 compatibility. For other character sets, or to disable UTF-8 support entirely, change the 'charset' property or renderEscaped method on subclasses.

Justin Hileman 15 anni fa
parent
commit
4baf602eab
1 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  1. 4 1
      Mustache.php

+ 4 - 1
Mustache.php

@@ -22,6 +22,9 @@ class Mustache {
 	protected $throwPartialExceptions  = false;
 	protected $throwVariableExceptions = false;
 
+	// Override charset passed to htmlentities() and htmlspecialchars(). Defaults to UTF-8.
+	protected $charset = 'UTF-8';
+	
 	protected $tagRegEx;
 
 	protected $template = '';
@@ -232,7 +235,7 @@ class Mustache {
 	 * @return string
 	 */
 	protected function renderEscaped($tag_name, &$context) {
-		return htmlentities($this->getVariable($tag_name, $context));
+		return htmlentities($this->getVariable($tag_name, $context), null, $this->charset);
 	}
 
 	/**