From 46644f049bd66bba10c79b84004ec5dd2fcae7fb Mon Sep 17 00:00:00 2001 From: David Santiago Date: Mon, 27 Jun 2011 17:26:31 -0500 Subject: [PATCH] Fix bug in inverted section handler found by @lolownia. --- src/stencil/ast.clj | 3 +-- test/stencil/test/core.clj | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/stencil/ast.clj b/src/stencil/ast.clj index a329551..9b1c8a1 100644 --- a/src/stencil/ast.clj +++ b/src/stencil/ast.clj @@ -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))))) diff --git a/test/stencil/test/core.clj b/test/stencil/test/core.clj index 241d8fa..4f33467 100644 --- a/test/stencil/test/core.clj +++ b/test/stencil/test/core.clj @@ -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"]}))))