I recently came across a discussion about eager loading HAML templates on this website. The concept of caching HTML partials to enhance performance in Angular applications caught my attention. However, I'm curious to know if there is a similar approach for erb/HTML templates without using HAML. In the code snippet provided:
$templateCache.put("<%= File.basename(f).gsub(/\.haml$/, '') %>", <%= Haml::Engine.new(File.read(f)).render.to_json %>);
<% end %>
It mentions using Haml::Engine.new
for HAML templates, but what would be the equivalent method for erb templates? If anyone has a suggestion or solution for implementing this technique with non-HAML templates, please share your insights.