Skip to content

Commit

Permalink
HTML: check for templates in style/script
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Oct 31, 2023
1 parent de6a78e commit e7c20a5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions html/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (l *Lexer) Next() (TokenType, []byte) {
}

if l.rawTag != 0 {
if rawText := l.shiftRawText(); len(rawText) > 0 {
if rawText := l.shiftRawText(); 0 < len(rawText) {
l.text = rawText
l.rawTag = 0
return TextToken, rawText
Expand Down Expand Up @@ -193,7 +193,7 @@ func (l *Lexer) Next() (TokenType, []byte) {
l.moveTemplate()
l.hasTmpl = true
} else if c == 0 && l.r.Err() != nil {
if l.r.Pos() > 0 {
if 0 < l.r.Pos() {
l.text = l.r.Shift()
return TextToken, l.text
}
Expand Down Expand Up @@ -274,6 +274,10 @@ func (l *Lexer) shiftRawText() []byte {
} else {
l.r.Move(1)
}
} else if 0 < len(l.tmplBegin) && l.at(l.tmplBegin...) {
l.r.Move(len(l.tmplBegin))
l.moveTemplate()
l.hasTmpl = true
} else if c == 0 && l.r.Err() != nil {
return l.r.Shift()
} else {
Expand Down

0 comments on commit e7c20a5

Please sign in to comment.