diff --git a/src/selmer/filter_parser.clj b/src/selmer/filter_parser.clj index 0c4ff3c..0e9ecfc 100644 --- a/src/selmer/filter_parser.clj +++ b/src/selmer/filter_parser.clj @@ -138,7 +138,9 @@ applied filter." "Returns the value of `k` from map `m`, either as a keyword or string lookup." (or (get m k) (when (keyword? k) - (get m (name k))))) + (if-let [n (namespace k)] + (get m (str n "/" (name k))) + (get m (name k)))))) (defn compile-filter-body "Turns a string like foo|filter1:x|filter2:y into a fn that expects a diff --git a/test/selmer/core_test.clj b/test/selmer/core_test.clj index cd64d94..a5dfbd2 100644 --- a/test/selmer/core_test.clj +++ b/test/selmer/core_test.clj @@ -807,7 +807,8 @@ (deftest name-test (testing "converts keywords to strings" - (is (= "foobar" (render "{{foo|name}}" {:foo :foobar})))) + (is (= "foobar" (render "{{foo|name}}" {:foo :foobar}))) + (is (= "foobar" (render "{{foo/bar}}" {"foo/bar" "foobar"})))) (testing "leaves strings as they are" (is (= "foobar" (render "{{foo|name}}" {:foo "foobar"})))))