Skip to content

Include your angular templates as part of the Rails assets pipeline.

License

Notifications You must be signed in to change notification settings

tye/angular-templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Angular Templates for Rails

Installation

Add to your Gemfile:

gem 'angular-templates'

And then execute:

$ bundle

Add a config option to application.rb to set the module name the templates will be added to

module YourApp
  class Application < Rails::Application
    config.angular_templates.module_name = 'app'
  end
end

Usage

In your application.js add

//= require angular-templates

And then add your angular templates to the app/templates directory. These templates will automatically be added to Angular's $templateCache.

For example, the template app/templates/users/show.erb will be added to $templateCache as users/show.

Compatibility

This has been tested with Rails 4.0+.

Helpers

All of your helpers will be included and can be used in your templates. Since the templates are rendered as part of the assets pipeline they will not have access to controller instance variables or methods (like cookies or session).

Partials

You can render partials inside your template. For example if you have app/templates/users/_form.erb then in app/templates/users/new.erb you can have:

...
<%= render 'users/form' %>
...

Partials will not be added to $templateCache.

Todo

  • Fix problems where file doesn't always update after a new file is created
  • Add test code

About

Include your angular templates as part of the Rails assets pipeline.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published