Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrukowski committed Oct 31, 2024
1 parent ae11087 commit 1708140
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 37 deletions.
29 changes: 0 additions & 29 deletions [email protected]

This file was deleted.

16 changes: 8 additions & 8 deletions Sources/Lexer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,23 @@ func preprocess(template: String, options: PreprocessOptions = PreprocessOptions
template.removeLast()
}

template = template.replacing(/{#.*?#}/, with: "{##}")
template = template.replacing(#/{#.*?#}/#, with: "{##}")

if options.lstripBlocks == true {
template = template.replacing(/(?m)^[ \t]*({[#%])/, with: { $0.output.1 })
template = template.replacing(#/(?m)^[ \t]*({[#%])/#, with: { $0.output.1 })
}

if options.trimBlocks == true {
template = template.replacing(/([#%]})\n/, with: { $0.output.1 })
template = template.replacing(#/([#%]})\n/#, with: { $0.output.1 })
}

return
template
.replacing(/{##}/, with: "")
.replacing(/-%}\s*/, with: "%}")
.replacing(/\s*{%-/, with: "{%")
.replacing(/-}}\s*/, with: "}}")
.replacing(/\s*{{-/, with: "{{")
.replacing(#/{##}/#, with: "")
.replacing(#/-%}\s*/#, with: "%}")
.replacing(#/\s*{%-/#, with: "{%")
.replacing(#/-}}\s*/#, with: "}}")
.replacing(#/\s*{{-/#, with: "{{")
}

func tokenize(_ source: String, options: PreprocessOptions = PreprocessOptions()) throws -> [Token] {
Expand Down

0 comments on commit 1708140

Please sign in to comment.