Permalink
Browse files

allow string interpolation in string literal

  • Loading branch information...
1 parent da93650 commit deeb22143ee2d0b5046ee19cebca9d241913707d @mmikulicic committed Jul 9, 2010
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/haml_macro/core.clj
@@ -66,9 +66,18 @@
(apply vector (filter not-nil? (apply vector t attrs inline body))))
+(defn not-char-of [s]
+ (satisfy #(not (contains? s %))))
(defn quotedString [ch]
- (between (is-char ch) (is-char ch) (many (not-char ch))))
+ (let [quoteSeparator (is-char ch)
+ stringBody (many1 (not-char-of #{ch \#}))
+ expressionBody (let-bind [_ (string "#{")
+ expr (many1 (not-char \}))
+ _ (string "}")]
+ (result expr))
+ expansionBody (many (either stringBody expressionBody))]
+ (>>== (between quoteSeparator quoteSeparator expansionBody) #(apply concat %))))
(def hamlStringLiteral
(stringify (lexeme (either (quotedString \') (quotedString \")))))

0 comments on commit deeb221

Please sign in to comment.