Accessors are separated by dots like {{ foo.bar.0 }} which gets translated into (get-in context-map [:foo :bar 0]). So you can nest vectors and maps in your context-map.
Filters can be applied by separating then from the accessor with pipes: {{ foo|lower|capitalize }}. They are applied one after the other from left to right. Arguments can be passed to a filter separated by colons: {{ foo|pluralize:y:ies }}. If an argument includes spaces you can enclose it with doublequotes or colons: {{ foo|join:", " }}.
You can escape doublequotes inside doublequotes. And you can put colons inside doublequotes which will be ignored for the purpose of separating arguments.
Accessors are separated by dots like {{ foo.bar.0 }} which gets translated into (get-in context-map [:foo :bar 0]). So you can nest vectors and maps in your context-map. Filters can be applied by separating then from the accessor with pipes: {{ foo|lower|capitalize }}. They are applied one after the other from left to right. Arguments can be passed to a filter separated by colons: {{ foo|pluralize:y:ies }}. If an argument includes spaces you can enclose it with doublequotes or colons: {{ foo|join:", " }}. You can escape doublequotes inside doublequotes. And you can put colons inside doublequotes which will be ignored for the purpose of separating arguments.
(compile-filter-body s)
(compile-filter-body s escape?)
Turns a string like foo|filter1:x|filter2:y into a fn that expects a context-map and will apply the filters one after the other to the value from the map. It will escape the end result unless the last filter is "safe" or when it's called with escape? equal to true, which is the default behavior.
Turns a string like foo|filter1:x|filter2:y into a fn that expects a context-map and will apply the filters one after the other to the value from the map. It will escape the end result unless the last filter is "safe" or when it's called with escape? equal to true, which is the default behavior.
(escape-html x)
Must have the form [:safe safe-string] to prevent escaping. Alternatively, you can call selmer.util/turn-off-escaping! to turn it off completely.
If it is marked as :safe, the value will be returned as-is, otherwise it will be converted to a string even if it is not escaped.
Must have the form [:safe safe-string] to prevent escaping. Alternatively, you can call selmer.util/turn-off-escaping! to turn it off completely. If it is marked as :safe, the value will be returned as-is, otherwise it will be converted to a string even if it is not escaped.
(escape-html* s)
HTML-escapes the given string. Escapes the same characters as django's escape.
HTML-escapes the given string. Escapes the same characters as django's escape.
(filter-str->fn s)
Turns a filter string like "pluralize:y:ies" into a function that expects a value obtained from a context map or from a previously applied filter.
Turns a filter string like "pluralize:y:ies" into a function that expects a value obtained from a context map or from a previously applied filter.
(fix-filter-args args)
Map any sort of needed fixes to the arguments before passing them to the filters. Only strips enclosing doublequotes for now.
Map any sort of needed fixes to the arguments before passing them to the filters. Only strips enclosing doublequotes for now.
(get-accessor m k)
Returns the value of k
from map m
, either as a keyword or string lookup.
Returns the value of `k` from map `m`, either as a keyword or string lookup.
(lookup-args context-map)
Given a context map, return a function that accepts a filter argument and if it begins with @, return the value from the context map instead of treating it as a literal.
Given a context map, return a function that accepts a filter argument and if it begins with @, return the value from the context map instead of treating it as a literal.
(strip-doublequotes s)
Removes doublequotes from the start and end of a string if any.
Removes doublequotes from the start and end of a string if any.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close