angular_template 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 046f7f71bed9b26dd7f70526d047412ea640a85d
4
+ data.tar.gz: 1b046df642545ba66f32a733706185b067672157
5
+ SHA512:
6
+ metadata.gz: 012acb7929319ddc5a5da1910f18e74018290da9d2befd097dc4f3eed917dd04aaa2f8deada30cc030a09a1363ecb4d34bed985466d4f980f21cc074c8f1ec58
7
+ data.tar.gz: 8df7d72e155790acd69fc96e1a9ef2926ee828cb993411aeca14175f65490006384b18397760083792e9c35af742e7f1166155b0f02bb3c26ea8fafec36dbf73
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in angular_template.gemspec
4
+ gemspec
5
+
6
+ gem 'pry'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 undr
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,73 @@
1
+ # AngularTemplate
2
+
3
+ The handy way to utilize angular templates in rails using Sprockets
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'angular_template'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```
22
+ $ gem install angular_template
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ 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.
28
+
29
+
30
+ For example, this template:
31
+
32
+ ```html
33
+ <!-- templates/some_template.ahtml -->
34
+ <div>{name}</div>
35
+ ```
36
+
37
+ will be converted into:
38
+
39
+ ```javascript
40
+ angular.module('application.templates').run(function($templateCache){
41
+ $templateCache.put('some_template', '<!-- templates/some_template.ahtml -->\n<div>{name}</div>')
42
+ });
43
+ ```
44
+
45
+ and this:
46
+
47
+ ```html
48
+ <!-- ui/toolbox/templates/some_template.ahtml -->
49
+ <div>{name}</div>
50
+ ```
51
+
52
+ into:
53
+
54
+ ```javascript
55
+ angular.module('application.ui.toolbox.templates').run(function($templateCache){
56
+ $templateCache.put('ui/toolbox/some_template', '<!-- ui/toolbox/templates/some_template.ahtml -->\n<div>{name}</div>')
57
+ });
58
+ ```
59
+
60
+ Respectively they can be accessed by using following paths:
61
+
62
+ ```
63
+ templateUrl: 'some_template'
64
+ templateUrl: 'ui/toolbox/some_template'
65
+ ```
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it ( https://github.com/undr/angular_template/fork )
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
72
+ 4. Push to the branch (`git push origin my-new-feature`)
73
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'angular_template/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'angular_template'
8
+ spec.version = AngularTemplate::VERSION
9
+ spec.authors = ['undr']
10
+ spec.email = ['undr@yandex.ru']
11
+ spec.summary = %q{The handy way to utilize angular templates in rails using Sprockets}
12
+ spec.description = %q{The handy way to utilize angular templates in rails using Sprockets}
13
+ spec.homepage = 'https://github.com/undr/angular_template'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'rails', '>= 4.0.0', '< 5.0'
22
+ spec.add_dependency 'tilt', '~> 1.1'
23
+
24
+ spec.add_development_dependency 'bundler', "~> 1.6"
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'slim'
27
+ end
@@ -0,0 +1,7 @@
1
+ require "angular_template/version"
2
+ require "angular_template/html"
3
+ require "angular_template/slim" if defined?(::Slim::Template)
4
+ require "angular_template/engine"
5
+
6
+ module AngularTemplate
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rails'
2
+
3
+ module AngularTemplate
4
+ class Engine < Rails::Engine
5
+ initializer 'angular_template.environment', after: 'sprockets.environment' do |app|
6
+ app.assets.register_engine('.ahtml', Html)
7
+ app.assets.register_engine('.aslim', Slim) if defined?(Slim)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,37 @@
1
+ require 'tilt'
2
+ require 'action_view'
3
+
4
+ module AngularTemplate
5
+ class Html < Tilt::Template
6
+ include ActionView::Helpers::JavaScriptHelper
7
+
8
+ def prepare
9
+ @data += "\n" if data != '' && data !~ /\n\Z/m
10
+ end
11
+
12
+ def evaluate(context, locals, &block)
13
+ @context = context
14
+ "angular.module('application.%stemplates').run(function($templateCache){ $templateCache.put('%s', '%s') });" % arguments
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :context
20
+
21
+ def escaped_body
22
+ escape_javascript(data)
23
+ end
24
+
25
+ def arguments
26
+ [module_name, template_name, escaped_body]
27
+ end
28
+
29
+ def module_name
30
+ @module_name ||= context.logical_path.split('templates/').first.gsub('/', '.')
31
+ end
32
+
33
+ def template_name
34
+ @template_name ||= context.logical_path.split('templates/').join
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,9 @@
1
+ module AngularTemplate
2
+ class Slim < Html
3
+ private
4
+
5
+ def escaped_body
6
+ escape_javascript(::Slim::Template.new({}){ data }.render({}))
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module AngularTemplate
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: angular_template
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - undr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 4.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: tilt
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.1'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.1'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.6'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.6'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: slim
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description: The handy way to utilize angular templates in rails using Sprockets
90
+ email:
91
+ - undr@yandex.ru
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - Gemfile
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - angular_template.gemspec
102
+ - lib/angular_template.rb
103
+ - lib/angular_template/engine.rb
104
+ - lib/angular_template/html.rb
105
+ - lib/angular_template/slim.rb
106
+ - lib/angular_template/version.rb
107
+ homepage: https://github.com/undr/angular_template
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.4.6
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: The handy way to utilize angular templates in rails using Sprockets
131
+ test_files: []