             case .text(let startIndex, let startLineNumber):
                 if c == "\n" {
                     lineNumber += 1
-                } else if atString(i, currentDelimiters.unescapedTagStart) {
+                } else if index(i, isAt: currentDelimiters.unescapedTagStart, in: templateString) {
                     if startIndex != i {
                         let range = startIndex..<i
                         let token = TemplateToken(

                    state = .setDelimitersTag(startIndex: i, startLineNumber: lineNumber)
                    i = templateString.index(i, offsetBy: currentDelimiters.setDelimitersStartLength)
                    i = templateString.index(before: i)
                } else if atString(i, currentDelimiters.tagDelimiterPair.0) {
                    if startIndex != i {
                        let range = startIndex..<i
                        let token = TemplateToken(

                    state = .unescapedTag(startIndex: i, startLineNumber: lineNumber)
                    i = templateString.index(i, offsetBy: currentDelimiters.unescapedTagStartLength)
                    i = templateString.index(before: i)
                } else if index(i, isAt: currentDelimiters.setDelimitersStart, in: templateString) {
                    if startIndex != i {
                        let range = startIndex..<i
                        let token = TemplateToken(
