Skip to content

Commit

Permalink
Support for newlines inside mustache tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Aug 3, 2010
1 parent c1cdea7 commit ec562fe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Mustache.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected function _renderTemplate($template) {
protected function _renderSection($template) {
$otag = preg_quote($this->_otag, '/');
$ctag = preg_quote($this->_ctag, '/');
$regex = '/' . $otag . '(\\^|\\#)\\s*(.+?)\\s*' . $ctag . '\\s*([\\s\\S]+?)' . $otag . '\\/\\s*\\2\\s*' . $ctag . '\\s*/m';
$regex = '/' . $otag . '(\\^|\\#)\\s*(.+?)\\s*' . $ctag . '\\s*([\\s\\S]+?)' . $otag . '\\/\\s*\\2\\s*' . $ctag . '\\s*/ms';

$matches = array();
while (preg_match($regex, $template, $matches, PREG_OFFSET_CAPTURE)) {
Expand Down Expand Up @@ -284,7 +284,7 @@ protected function _renderPragmas($template) {

$otag = preg_quote($this->_otag, '/');
$ctag = preg_quote($this->_ctag, '/');
$regex = '/' . $otag . '%\\s*([\\w_-]+)((?: [\\w]+=[\\w]+)*)\\s*' . $ctag . '\\n?/';
$regex = '/' . $otag . '%\\s*([\\w_-]+)((?: [\\w]+=[\\w]+)*)\\s*' . $ctag . '\\n?/s';
return preg_replace_callback($regex, array($this, '_renderPragma'), $template);
}

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

$html = '';
$matches = array();
Expand Down Expand Up @@ -523,7 +523,7 @@ protected function _changeDelimiter($tag_name) {

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

Expand Down

0 comments on commit ec562fe

Please sign in to comment.