Skip to content

Commit

Permalink
Fix bug in inverted section handler found by @lolownia.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsantiago committed Jun 27, 2011
1 parent 67347d8 commit 46644f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/stencil/ast.clj
Expand Up @@ -51,8 +51,7 @@
ctx-val (context-get context-stack name)]
;; Per the spec, a function is truthy, so we should not render.
(if (and (not (instance? clojure.lang.Fn ctx-val))
(or (not (contains? ctx name))
(not ctx-val)
(or (not ctx-val)
(and (sequential? ctx-val)
(empty? ctx-val))))
(render contents sb context-stack)))))
Expand Down
7 changes: 7 additions & 0 deletions test/stencil/test/core.clj
Expand Up @@ -2,4 +2,11 @@
(:use clojure.test
stencil.core))

;; Test case to make sure we don't get a regression on inverted sections with
;; list values for a name.

(deftest inverted-section-list-key-test
(is (= ""
(render-string "{{^a}}a{{b}}a{{/a}}" {:a [:b "11"]})))
(is (= ""
(render-string "{{^a}}a{{b}}a{{/a}}" {"a" ["b" "11"]}))))

0 comments on commit 46644f0

Please sign in to comment.