Skip to content

Instantly share code, notes, and snippets.

@dagda1
Created June 29, 2011 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dagda1/1053719 to your computer and use it in GitHub Desktop.
Save dagda1/1053719 to your computer and use it in GitHub Desktop.
rails_js_template.rb
<%
dir = Rails.root.join('public/javascripts/app/templates/')
Dir["#{dir}**/*.*"].each do |path|
%>
<%
template = File.read(path)
name = path.gsub(dir.to_s, '').sub(File.extname(path), '')
%>
<script name="<%= name %>" type="text/x-js-template"><%= template.html_safe %></script>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment