diff --git a/app/page-data.inc.php b/app/page-data.inc.php index 8b186e84..c3ffd83a 100644 --- a/app/page-data.inc.php +++ b/app/page-data.inc.php @@ -194,6 +194,9 @@ static function create_textfile_vars($page) { # include shared variables for each page $shared = (file_exists('./content/_shared.txt')) ? file_get_contents('./content/_shared.txt') : ''; + # strip any $n matches from the text, as this will mess with any preg_replaces + # they get put back in after the template has finished being parsed + $text = preg_replace('/\$(\d+)/', "\x02$1", $text); # remove UTF-8 BOM and marker character in input, if present $merged_text = preg_replace('/^\xEF\xBB\xBF|\x1A/', '', array($shared, $text)); diff --git a/app/parsers/template-parser.inc.php b/app/parsers/template-parser.inc.php index b7dd7472..2669370f 100644 --- a/app/parsers/template-parser.inc.php +++ b/app/parsers/template-parser.inc.php @@ -88,6 +88,8 @@ static function parse($data, $template) { # we've finished parsing, so return any remaining @ symbols $template = str_replace("\x01", '@', $template); + # put back any $ characters + $template = str_replace("\x02", '$', $template); return $template; }