diff options
Diffstat (limited to 'src/html/template/context.go')
| -rw-r--r-- | src/html/template/context.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/html/template/context.go b/src/html/template/context.go index e07a0c4a02..7987713c65 100644 --- a/src/html/template/context.go +++ b/src/html/template/context.go @@ -174,6 +174,20 @@ func isInTag(s state) bool { return false } +// isInScriptLiteral returns true if s is one of the literal states within a +// <script> tag, and as such occurances of "<!--", "<script", and "</script" +// need to be treated specially. +func isInScriptLiteral(s state) bool { + // Ignore the comment states (stateJSBlockCmt, stateJSLineCmt, + // stateJSHTMLOpenCmt, stateJSHTMLCloseCmt) because their content is already + // omitted from the output. + switch s { + case stateJSDqStr, stateJSSqStr, stateJSBqStr, stateJSRegexp: + return true + } + return false +} + // delim is the delimiter that will end the current HTML attribute. type delim uint8 |
