We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2551324 commit 65deb9cCopy full SHA for 65deb9c
src/text/template/parse/lex.go
@@ -369,7 +369,7 @@ func lexComment(l *lexer) stateFn {
369
370
// lexRightDelim scans the right delimiter, which is known to be present, possibly with a trim marker.
371
func lexRightDelim(l *lexer) stateFn {
372
- trimSpace := hasRightTrimMarker(l.input[l.pos:])
+ _, trimSpace := l.atRightDelim()
373
if trimSpace {
374
l.pos += trimMarkerLen
375
l.ignore()
src/text/template/parse/lex_test.go
@@ -491,6 +491,23 @@ func TestDelimsAlphaNumeric(t *testing.T) {
491
}
492
493
494
+func TestDelimsAndMarkers(t *testing.T) {
495
+ test := lexTest{"delims that look like markers", "{{- .x -}} {{- - .x - -}}", []item{
496
+ mkItem(itemLeftDelim, "{{- "),
497
+ mkItem(itemField, ".x"),
498
+ mkItem(itemRightDelim, " -}}"),
499
500
501
502
+ tEOF,
503
+ }}
504
+ items := collect(&test, "{{- ", " -}}")
505
+
506
+ if !equal(items, test.items, false) {
507
+ t.Errorf("%s: got\n\t%v\nexpected\n\t%v", test.name, items, test.items)
508
+ }
509
+}
510
511
var lexPosTests = []lexTest{
512
{"empty", "", []item{{itemEOF, 0, "", 1}}},
513
{"punctuation", "{{,@%#}}", []item{
0 commit comments