selmer.filter-parser
(source)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.
For more info about this library see:
https://rawgit.com/yogthos/Selmer/master/docs/uberdoc.htmlPublic Variable | Short Description |
---|---|
compile-filter-body (clj) | 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. |
escape-html (clj) | Must have the form [:safe safe-string] to prevent escaping. |
escape-html* (clj) | HTML-escapes the given string. |
filter-str->fn (clj) | 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 (clj) | Map any sort of needed fixes to the arguments before passing them to the filters. |
get-accessor (clj) | Returns the value of `k` from map `m`, either as a keyword or string lookup. |
literal? (clj) | |
lookup-args (clj) | 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. |
parse-literal (clj) | |
safe-filter (clj) | |
split-value (clj) | |
strip-doublequotes (clj) | Removes doublequotes from the start and end of a string if any. |