File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -53,10 +53,14 @@ typealias AST = [ASTNode]
5353// MARK: - Helper Extensions
5454
5555extension StringProtocol {
56- /// The code content from a gyb block (%{...}%) .
56+ /// The code content from a gyb block, with delimiters and optional trailing newline removed .
5757 ///
58- /// Removes the %{ prefix, }% suffix, and optional trailing newline .
58+ /// - Precondition: `self` starts with `%{` and ends with `}%` or `}%\n` .
5959 var codeBlockContent : SubSequence {
60+ precondition ( hasPrefix ( " %{ " ) , " Expected %{ prefix " )
61+ precondition (
62+ hasSuffix ( " }% " ) || hasSuffix ( " }% \n " ) ,
63+ " Expected }% suffix with optional newline " )
6064 let suffixLength = last? . isNewline == true ? 3 : 2 // }%\n or }%
6165 return dropFirst ( 2 ) . dropLast ( suffixLength)
6266 }
You can’t perform that action at this time.
0 commit comments