Created
May 27, 2014 18:53
-
-
Save vgdub/ae37669fc6f587223a61 to your computer and use it in GitHub Desktop.
template_cache_rails_assets_angular.js.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('templates', []).run([ '$templateCache', function($templateCache) { | |
<% | |
environment.context_class.instance_eval { include ActionView::Helpers::JavaScriptHelper } | |
app_root = File.expand_path('../', __FILE__) | |
html_templates = File.join(app_root, %w{templates ** ** *.html }) | |
templates = Dir.glob(html_templates) | |
templates.each do |f| | |
depend_on(f) | |
key = f.gsub(%r(^#{app_root}/templates/),'').split('.').first | |
content = environment.find_asset(f).body | |
%> | |
$templateCache.put("<%= key %>.html", "<%= escape_javascript(content) %>" ); | |
<% end %> | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment