Skip to content

Instantly share code, notes, and snippets.

@mmoss
Created March 20, 2012 00:56
Show Gist options
  • Save mmoss/2129284 to your computer and use it in GitHub Desktop.
Save mmoss/2129284 to your computer and use it in GitHub Desktop.
Easy way of loading templates using icanhaz.js
!function(){
<% Dir.glob("#{Rails.root}/app/javascripts/templates/**/*.html.haml.mustache").each do |template| %>
ich.addTemplate(
"<%= File.basename template, '.html.haml.mustache' %>",
"<%= Haml::Engine.new(File.open(template, 'rb').read()).render.gsub(/\"/, '\\\"').gsub(/\n|[ ]{2,}/,'') %>"
);
<% end %>
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment