Description
Our company is using Selmer to format user-provided strings in our system. With that said, it would be nice to be able to do some of the things below. Some of these may go against Selmer philosophy, but it's worth a discussion. This may help Selmer gain adoption in more applications than the normal server-sider rendering.
Disabling Tags
It would be nice if there was some mechanism to disable tag parsing all together. Our company really only wants to do variables and filters. It would be nice to get this result:
(render "Hello {{name}}, {% blah %} how are you?" {:name "John"})
=> "Hello John, {% blah %} how are you?"
We can do this by setting tag-second to something like #"" but it would be clearer/cleaner if it was a global policy similar to (validate-off!)
Disabling Filters
While our company doesn't have this requirement, it may make sense to add this in relation to the above.
Missing Values
Right now this is the current behavior:
(render "Hello {{name}}, how are you?" {})
=> "Hello , how are you?"
Our company would prefer this say something like Hello {{name}}, how are you? or Hello <name not provided>, how are you? instead. What if we implemented something like this when a lookup fails in the context-map?
(set-missing-value-formatter!
(fn [arg context-map]
(comment "We could do what ever we want with the arg here, maybe even reference another value in the context-map, throw an exception, etc.")
(str "<" (name arg) " not provided>")))
And it could simply default to (constantly "")
Exceptions
As we're dealing with user provided strings, we would prefer (as we deal with emergencies) that no exceptions be thrown when there is a parse failure, but instead, simply return the failed tokens. What I mean by that is this:
(render "Hello {{name | this-filter-does-not-exist}}, how are you?" {:name "John"})
=> "Hello {{name|this-filter-does-not-exist}}, how are you?"
(render "Hello {% does-not-exist-tag %}, how are you?" {:name "John"})
=> "Hello {% does-not-exist-tag %}, how are you?""
Right now we have a solution for all of the above by manually looping though the selmer.node.INodes and manually calling .render-node but it would be neat to have some of these configurable as global policies.
Thoughts?