AngularTemplate
The handy way to utilize angular templates in rails using Sprockets
Installation
Add this line to your application's Gemfile:
gem 'angular_template'And then execute:
$ bundle
Or install it yourself as:
$ gem install angular_template
Usage
Just put your angular templates in folder constructed by following pattern: #{module}/templates/template_name. This module can be a chain of modules. Eg. application.ui.toolbox. It means, templates for module application.ui.toolbox should be placed in folder ui/toolbox/templates. Also module application.ui.toolbox.templates will be created.
For example, this template:
<!-- templates/some_template.ahtml -->
<div>{name}</div>will be converted into:
angular.module('application.templates').run(function($templateCache){
$templateCache.put('some_template', '<!-- templates/some_template.ahtml -->\n<div>{name}</div>')
});and this:
<!-- ui/toolbox/templates/some_template.ahtml -->
<div>{name}</div>into:
angular.module('application.ui.toolbox.templates').run(function($templateCache){
$templateCache.put('ui/toolbox/some_template', '<!-- ui/toolbox/templates/some_template.ahtml -->\n<div>{name}</div>')
});Respectively they can be accessed by using following paths:
templateUrl: 'some_template'
templateUrl: 'ui/toolbox/some_template'
Contributing
- Fork it ( https://github.com/undr/angular_template/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request