Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Oct 30, 2010
2 parents 8b1c9c1 + 35c7250 commit a39c6f6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Mustache.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ protected function _renderTags($template) {
$otag = preg_quote($this->_otag, '/');
$ctag = preg_quote($this->_ctag, '/');

$this->_tagRegEx = '/' . $otag . "([#\^\/=!>\\{&])?(.+?)\\1?" . $ctag . "+/s";
$this->_tagRegEx = '/' . $otag . "([#\^\/=!<>\\{&])?(.+?)\\1?" . $ctag . "+/s";

$html = '';
$matches = array();
Expand Down Expand Up @@ -442,6 +442,7 @@ protected function _renderTag($modifier, $tag_name) {
return $this->_renderComment($tag_name);
break;
case '>':
case '<':
return $this->_renderPartial($tag_name);
break;
case '{':
Expand Down Expand Up @@ -469,7 +470,7 @@ protected function _renderTag($modifier, $tag_name) {
* @return string
*/
protected function _renderEscaped($tag_name) {
return htmlentities($this->_getVariable($tag_name), null, $this->_charset);
return htmlentities($this->_getVariable($tag_name), ENT_COMPAT, $this->_charset);
}

/**
Expand Down Expand Up @@ -521,7 +522,7 @@ protected function _changeDelimiter($tag_name) {

$otag = preg_quote($this->_otag, '/');
$ctag = preg_quote($this->_ctag, '/');
$this->_tagRegEx = '/' . $otag . "([#\^\/=!>\\{&])?(.+?)\\1?" . $ctag . "+/s";
$this->_tagRegEx = '/' . $otag . "([#\^\/=!<>\\{&])?(.+?)\\1?" . $ctag . "+/s";
return '';
}

Expand Down Expand Up @@ -608,7 +609,7 @@ protected function _findVariableInContext($tag_name, $context) {
} else if (isset($view->$tag_name)) {
return $view->$tag_name;
}
} else if (isset($view[$tag_name])) {
} else if (array_key_exists($tag_name, $view)) {
return $view[$tag_name];
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/escaped/Escaped.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

class Escaped extends Mustache {
public $title = "Bear > Shark";
public $title = '"Bear" > "Shark"';
}
2 changes: 1 addition & 1 deletion examples/escaped/escaped.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h1>Bear &gt; Shark</h1>
<h1>&quot;Bear&quot; &gt; &quot;Shark&quot;</h1>

1 comment on commit a39c6f6

@bobthecow
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix a couple of quirks:

  1. Double quotes are now escaped, per the mustache spec.
  2. Associative arrays containing null values now work as expected (see http://hile.mn/8ZUs8m)

Please sign in to comment.