angular-rails-templates 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Angular Rails Templates
1
+ # Angular Rails Templates [![Build Status](https://secure.travis-ci.org/dmathieu/angular-rails-templates.png?branch=master)](http://travis-ci.org/dmathieu/angular-rails-templates)
2
2
 
3
3
  Behind the hideous Angular Rails Templates name is hiding a template management system for rails' asset pipeline and AngularJS' template views.
4
4
 
@@ -20,6 +20,24 @@ Then, in your `application.js` file, require your templates and the internal jav
20
20
  The `require angular-rails-templates` **needs** to happen after requiring all your templates. Otherwise, they won't be loaded.
21
21
  Your template files can have the extensions **.html** or **.ajs**
22
22
 
23
+ In your application, add a dependency to the `templates` module.
24
+
25
+ var application = angular.module('myApplication', ['templates']);
26
+
27
+ Loading this module will automatically load all your templates into angular's `$templateCache`.
28
+ Angular uses this parameter when checking for the presence of templates before making an HTTP call.
29
+
30
+ ## How it works
31
+
32
+ Because of the way angular's modules work, we cannot create one templates module which would load all the templates.
33
+ Therefore, we create one module per template. It's callsed `templates-<template-name>`.
34
+
35
+ Also, because we cannot dynamically retrieve a list of all angular modules to find the ones matching our templates and include them, we add a root variable which contains the list of all our templates modules.
36
+ It is `window.AngularRailsTemplates`.
37
+
38
+ When you `require angular-rails-templates`, we create the `templates` module, which has dependencies to all the templates previously defined. Therefore including all our templates.
39
+ You can check the content of this `templates` module in [angular-rails-templates.js.erb](https://github.com/dmathieu/angular-rails-templates/blob/master/app/assets/javascripts/angular-rails-templates.js.erb).
40
+
23
41
  ## License
24
42
 
25
43
  MIT License. Copyright 2013 Damien Mathieu
@@ -10,13 +10,13 @@ module AngularRailsTemplates
10
10
  def prepare; end
11
11
 
12
12
  def evaluate(scope, locals, &block)
13
- key = file.split('/').last
14
- module_name = "#{configuration.module_name}-#{key.split('.')[0...-1].join('.')}"
13
+ module_name = configuration.module_name
14
+ logical_template_path = logical_template_path(scope)
15
15
 
16
16
  <<-EOS
17
- angular.module(#{module_name.inspect}, []).run(function($templateCache) {
18
- $templateCache.put(#{key.inspect}, #{data.to_json});
19
- });
17
+ angular.module(#{module_name.inspect}, []).run(["$templateCache",function($templateCache) {
18
+ $templateCache.put(#{logical_template_path.inspect}, #{data.to_json});
19
+ }]);
20
20
 
21
21
  if (typeof window.AngularRailsTemplates === 'undefined') {
22
22
  window.AngularRailsTemplates = [];
@@ -26,6 +26,10 @@ window.AngularRailsTemplates.push(#{module_name.inspect});
26
26
  end
27
27
 
28
28
  private
29
+ def logical_template_path(scope)
30
+ "#{scope.logical_path}.#{basename.split(".")[1]}"
31
+ end
32
+
29
33
  def configuration
30
34
  ::Rails.configuration.angular_templates
31
35
  end
@@ -1,3 +1,3 @@
1
1
  module AngularRailsTemplates
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angular-rails-templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,56 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-16 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2013-10-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: sprockets-rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: uglifier
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
14
62
  description:
15
63
  email:
16
64
  - 42@dmathieu.com
@@ -26,7 +74,8 @@ files:
26
74
  - lib/angular-rails-templates.rb
27
75
  - app/assets/javascripts/angular-rails-templates.js.erb
28
76
  homepage: https://github.com/dmathieu/angular-rails-templates
29
- licenses: []
77
+ licenses:
78
+ - MIT
30
79
  post_install_message:
31
80
  rdoc_options: []
32
81
  require_paths: