Skip to content
This repository was archived by the owner on Jun 10, 2018. It is now read-only.

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

Open
byroot wants to merge 2 commits intosstephenson:masterfrom
byroot:allow-to-customize-the-escape-function
Open

Allow to use a custom function to compile the escape pattern (<%- %>)#12
byroot wants to merge 2 commits intosstephenson:masterfrom
byroot:allow-to-customize-the-escape-function

Conversation

@byroot
Copy link
Contributor

@byroot byroot commented Nov 26, 2012

EJS.escape_function is now a formatting string.
Example:

EJS.escape_function = '_.escape(%s)'

EJS.escape_function is now a formatting string.
Example: EJS.escape_function = '_.escape(%s)'
@byroot
Copy link
Contributor Author

byroot commented Nov 26, 2012

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
Copy link

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

@wireframe
Copy link

+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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants