Skip to content

Commit 6d3ca97

Browse files
committed
HTML: fix bug for adjacent templates in attributes
1 parent 236908b commit 6d3ca97

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

html/lex.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,12 @@ func (l *Lexer) shiftStartTag() (TokenType, []byte) {
399399
func (l *Lexer) shiftAttribute() []byte {
400400
nameStart := l.r.Pos()
401401
var c byte
402-
if 0 < len(l.tmplBegin) && l.at(l.tmplBegin...) {
403-
l.r.Move(len(l.tmplBegin))
404-
l.moveTemplate()
405-
l.hasTmpl = true
402+
if 0 < len(l.tmplBegin) {
403+
for l.at(l.tmplBegin...) {
404+
l.r.Move(len(l.tmplBegin))
405+
l.moveTemplate()
406+
l.hasTmpl = true
407+
}
406408
}
407409
for { // attribute name state
408410
if c = l.r.Peek(0); c == ' ' || c == '=' || c == '>' || c == '/' && l.r.Peek(1) == '>' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == 0 && l.r.Err() != nil {

html/lex_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ func TestTemplates(t *testing.T) {
193193
{"{{", TTs{TemplateToken}, []bool{true}},
194194
{"{{'", TTs{TemplateToken}, []bool{true}},
195195
{"<tag{{.Attr}}>", TTs{StartTagToken, AttributeToken, StartTagCloseToken}, []bool{false, true, false}},
196+
{"<tag {{.Foo}}{{xx .Bar}}>", TTs{StartTagToken, AttributeToken, StartTagCloseToken}, []bool{false, true, false}},
196197
}
197198
for _, tt := range tests {
198199
t.Run(tt.html, func(t *testing.T) {

0 commit comments

Comments
 (0)