From 2ad6933fe74d162148a50763733cae88fec61502 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 17 Jun 2016 12:32:06 +0200 Subject: [PATCH] Compiler, Parser: renamed CONTEXT constants --- src/Latte/Compiler/Compiler.php | 53 ++++++++++++++++++-------------- src/Latte/Compiler/Parser.php | 18 +++++------ src/Latte/Compiler/PhpWriter.php | 22 ++++++------- src/Latte/Engine.php | 1 - src/Latte/Macros/MacroSet.php | 2 +- 5 files changed, 51 insertions(+), 45 deletions(-) diff --git a/src/Latte/Compiler/Compiler.php b/src/Latte/Compiler/Compiler.php index 20eb609d1..3014fb805 100644 --- a/src/Latte/Compiler/Compiler.php +++ b/src/Latte/Compiler/Compiler.php @@ -61,21 +61,28 @@ class Compiler private $properties = []; /** Context-aware escaping content types */ - const CONTENT_HTML = Engine::CONTENT_HTML, + const + CONTENT_HTML = Engine::CONTENT_HTML, CONTENT_XHTML = Engine::CONTENT_XHTML, CONTENT_XML = Engine::CONTENT_XML, CONTENT_JS = Engine::CONTENT_JS, CONTENT_CSS = Engine::CONTENT_CSS, - CONTENT_URL = Engine::CONTENT_URL, CONTENT_ICAL = Engine::CONTENT_ICAL, CONTENT_TEXT = Engine::CONTENT_TEXT; /** @internal Context-aware escaping HTML contexts */ const - CONTEXT_COMMENT = 'comment', - CONTEXT_BOGUS_COMMENT = 'bogus', - CONTEXT_QUOTED_ATTRIBUTE = 'attr', - CONTEXT_TAG = 'tag'; + // for CONTENT_HTML, CONTENT_XHTML + CONTEXT_HTML_TAG = 'tag', + CONTEXT_HTML_ATTRIBUTE = 'attr', + CONTEXT_HTML_ATTRIBUTE_URL = 'attrurl', + CONTEXT_HTML_COMMENT = 'comment', + CONTEXT_HTML_BOGUS_COMMENT = 'bogus', + CONTEXT_HTML_CSS = 'css', + CONTEXT_HTML_JS = 'js', + + CONTEXT_XML_TAG = self::CONTEXT_HTML_TAG, + CONTEXT_XML_COMMENT = self::CONTEXT_HTML_COMMENT; /** @@ -294,7 +301,7 @@ public function expandTokens($s) private function processText(Token $token) { - if ($this->context[0] === self::CONTEXT_QUOTED_ATTRIBUTE && $this->lastAttrValue === '') { + if ($this->context[0] === self::CONTEXT_HTML_ATTRIBUTE && $this->lastAttrValue === '') { $this->lastAttrValue = $token->text; } $this->output .= $this->escape($token->text); @@ -303,7 +310,7 @@ private function processText(Token $token) private function processMacroTag(Token $token) { - if (in_array($this->context[0], [self::CONTEXT_QUOTED_ATTRIBUTE, self::CONTEXT_TAG], TRUE)) { + if (in_array($this->context[0], [self::CONTEXT_HTML_ATTRIBUTE, self::CONTEXT_HTML_TAG], TRUE)) { $this->lastAttrValue = TRUE; } @@ -351,17 +358,17 @@ private function processHtmlTagBegin(Token $token) $this->setContext(NULL); } elseif ($token->text === '