                 if c == "\n" {
                     state = .text(startIndex: i, startLineNumber: lineNumber)
                     lineNumber += 1
-                } else if atString(i, currentDelimiters.unescapedTagStart) {
+                } else if index(i, isAt: currentDelimiters.unescapedTagStart, in: templateString) {
                     state = .unescapedTag(startIndex: i, startLineNumber: lineNumber)
                     i = templateString.index(i, offsetBy: currentDelimiters.unescapedTagStartLength)
                     i = templateString.index(before: i)
-                } else if atString(i, currentDelimiters.setDelimitersStart) {
+                } else if index(i, isAt: currentDelimiters.setDelimitersStart, in: templateString) {
                     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) {
+                } else if index(i, isAt: currentDelimiters.tagDelimiterPair.0, in: templateString) {
                     state = .tag(startIndex: i, startLineNumber: lineNumber)
                     i = templateString.index(i, offsetBy: currentDelimiters.tagStartLength)
                     i = templateString.index(before: i)

    func parse(_ templateString:String, templateID: TemplateID?) {
        var currentDelimiters = ParserTagDelimiters(tagDelimiterPair: tagDelimiterPair)
        
        let atString = { (index: String.Index, string: String?) -> Bool in
            guard let string = string else {
                return false
            }
            return String(templateString[index...]).hasPrefix(string)
        }
        
        var state: State = .start
        var lineNumber = 1
        var i = templateString.startIndex

            case .unescapedTag(let startIndex, let startLineNumber):
                if c == "\n" {
                    lineNumber += 1
                } else if index(i, isAt: currentDelimiters.unescapedTagEnd, in: templateString) {
                    let tagInitialIndex = templateString.index(startIndex, offsetBy: currentDelimiters.unescapedTagStartLength)
                    let content = String(templateString[tagInitialIndex..<i])
                    let token = TemplateToken(
