Allow to use a custom function to compile the escape pattern (<%- %>) #12

Open
wants to merge 2 commits into
from

3 participants

@byroot

EJS.escape_function is now a formatting string.
Example:

EJS.escape_function = '_.escape(%s)'
@byroot byroot Allow to use a custom function to compile the escape pattern (<%- %>)
EJS.escape_function is now a formatting string.
Example: EJS.escape_function = '_.escape(%s)'
f916b72
@byroot

And since _.escape and friend already take care of the string coercion https://github.com/documentcloud/underscore/blob/master/underscore.js#L1040
maybe we can let this responsibility to escape_function.

@percyhanna

Wow, I'd love to have this in the gem. Looks great.

@wireframe

+1

using a custom escape_function really cuts down on our compiled template size. since Underscore is already available in our app just using _.escape vs 6 inline replace statements is a pretty quick win!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment