Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eco JavaScript templates in Rails without duplicate code?

I am using 'eco' gem with my Rails application to load Eco templates. The templates are really handy and automatically loaded by Rails 3.1 asset pipeline. The only problem is that each .js file generated by eco includes the same javascript code that mainly deals with html escaping. The code is about 1.5K in non-minified form. It may become significant overhead if application uses a lot of templates (like a hundred of them). Is there a way to take this code out of the js files and include only once?

like image 625
Evgenii Avatar asked Apr 08 '26 04:04

Evgenii


1 Answers

See gist https://gist.github.com/2043682 , I have extracted out the common part.

like image 187
Ian Yang Avatar answered Apr 10 '26 17:04

Ian Yang