0.0
No commit activity in last 3 years
No release in over 3 years
Compile AngularJS templates to Javascript files
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.3
>= 0

Runtime

< 5.0, >= 4.0.0.beta
~> 2.9.3
~> 1.4.1
 Project Readme

html2js-rails

html2js, but for rails. Converts AngularJS templates to JS to store in cache, clientside.

Setup:

  • create an initializer:
# config/html2js.rb
Html2js.configure do |config|
  config.root = "#{Rails.root}/app/assets/templates"
end
  • Add the templates to the javascript manifest file:
// app/assets/javascripts/application.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
// require_tree .
//= require angular
//= require angular-resource
//= require_tree ../templates
//= require_tree ./angular
  • Place your templates in app/assets/templates, and make sure they end in .js.tpl.haml. That's what I use, that's what I know works. It should work with just .js.tpl, but I haven't tried it. It should equally work with, ERB, for example, but I haven't tried that either.

Contributing

Please feel free to fork, commit and send a pull request - or even just open an issue with recommendations for what you'd like to see improved!