html2js-rails 0.0.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +1 -0
- data/html2js-rails.gemspec +27 -0
- data/lib/html2js-rails.rb +4 -0
- data/lib/html2js/config.rb +18 -0
- data/lib/html2js/rails/engine.rb +6 -0
- data/lib/html2js/rails/template_handler.rb +49 -0
- data/lib/html2js/rails/version.rb +5 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 91b0ee85531435d83b27e60139d0e0a9edcde62b
|
4
|
+
data.tar.gz: e5a35965418eca75523cc094df2c4fc067ceb90a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b2836fdb06a399ae032a53c4d06605b8ff983467cf1fd4942f6ee15a2fc6550d2e5c8aeb84ff5e2a14d6c3c9ab028d15ec04f4b126797225423e019a2f1e1c1
|
7
|
+
data.tar.gz: e0e2226c457cd8f8f143132534248b3a3b05e69c175ae3c2f2c626e915108e032d084061598a6cff77d2b1cd713410ed7c4c968771d8f49ad87c05789349d2e3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 pccr
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# html2js-rails
|
2
|
+
html2js, but for rails. Converts AngularJS templates to JS to store in cache, clientside.
|
3
|
+
|
4
|
+
## Setup:
|
5
|
+
1. create an initializer:
|
6
|
+
```
|
7
|
+
# config/html2js.rb
|
8
|
+
Html2js.configure do |config|
|
9
|
+
config.root = "#{Rails.root}/app/assets/templates"
|
10
|
+
end
|
11
|
+
```
|
12
|
+
2. Add the templates to the javascript manifest file:
|
13
|
+
```
|
14
|
+
// app/assets/javascripts/application.js
|
15
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
16
|
+
// listed below.
|
17
|
+
//
|
18
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
19
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
20
|
+
//
|
21
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
22
|
+
// compiled file.
|
23
|
+
//
|
24
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
25
|
+
// GO AFTER THE REQUIRES BELOW.
|
26
|
+
//
|
27
|
+
// require_tree .
|
28
|
+
//= require angular
|
29
|
+
//= require angular-resource
|
30
|
+
//= require_tree ../templates
|
31
|
+
//= require_tree ./angular
|
32
|
+
```
|
33
|
+
3. Place your templates in `app/assets/templates`, and make sure they end in `.js.tpl.haml`. That's what I use,
|
34
|
+
that's what I know works. It *should* work with just `.js.tpl`, but I haven't tried it. It should equally work
|
35
|
+
with, ERB, for example, but I haven't tried that either.
|
36
|
+
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
Please, please contribute! I hacked this together for my own use; if people find it useful I'll continue working on
|
40
|
+
it. If I've completely missed some major point, please let me know! Otherwise, fork, commit,
|
41
|
+
and send a pull request!
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -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 'html2js/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "html2js-rails"
|
8
|
+
spec.version = Html2js::Rails::VERSION
|
9
|
+
spec.authors = ["pccr"]
|
10
|
+
spec.email = ["pcragone@gmail.com"]
|
11
|
+
spec.description = %q{Compile AngularJS templates to Javascript files}
|
12
|
+
spec.summary = %q{Compile AngularJS templates to Javascript files}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency 'railties', '>= 4.0.0.beta', '< 5.0'
|
25
|
+
spec.add_runtime_dependency 'tilt', '~> 1.4.1'
|
26
|
+
spec.add_runtime_dependency 'sprockets', '~> 2.9.3'
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Html2js
|
2
|
+
class << self
|
3
|
+
attr_accessor :configuration
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.configure
|
7
|
+
self.configuration ||= Configuration.new
|
8
|
+
yield(configuration)
|
9
|
+
end
|
10
|
+
|
11
|
+
class Configuration
|
12
|
+
attr_accessor :root
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@root = nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'sprockets'
|
3
|
+
|
4
|
+
module Html2js
|
5
|
+
class TemplateHandler < Tilt::Template
|
6
|
+
def self.default_mime_type
|
7
|
+
'application/javascript'
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.engine_initialized?
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize_engine
|
15
|
+
end
|
16
|
+
|
17
|
+
def prepare *args
|
18
|
+
end
|
19
|
+
|
20
|
+
def root_path
|
21
|
+
@@root_path ||= if Html2js.configuration.root =~ /\/$/
|
22
|
+
Html2js.configuration.root
|
23
|
+
else
|
24
|
+
"#{Html2js.configuration.root}/"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def evaluate(scope, locals, &block)
|
29
|
+
filename = file.gsub(root_path, '').gsub(/\.js/, '').gsub(/\.haml/, '.html')
|
30
|
+
<<EOT
|
31
|
+
try {
|
32
|
+
requirements = angular.module('templates').requires;
|
33
|
+
} catch (e) {
|
34
|
+
requirements = [];
|
35
|
+
}
|
36
|
+
requirements.push("#{filename}");
|
37
|
+
angular.module('templates', requirements);
|
38
|
+
angular.module("#{filename}", []).run(["$templateCache", function($templateCache) {
|
39
|
+
$templateCache.put("#{filename}",
|
40
|
+
"#{data.gsub(/"/, "\\\"").gsub(/\r?\n/, "\\n\" +\n \"")}"
|
41
|
+
);
|
42
|
+
}]);
|
43
|
+
EOT
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Sprockets.register_engine '.haml', Tilt::HamlTemplate
|
49
|
+
Sprockets.register_engine '.tpl', Html2js::TemplateHandler
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: html2js-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.rc1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pccr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 4.0.0.beta
|
48
|
+
- - <
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '5.0'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 4.0.0.beta
|
58
|
+
- - <
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '5.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: tilt
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.4.1
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 1.4.1
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: sprockets
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 2.9.3
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.9.3
|
89
|
+
description: Compile AngularJS templates to Javascript files
|
90
|
+
email:
|
91
|
+
- pcragone@gmail.com
|
92
|
+
executables: []
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- .gitignore
|
97
|
+
- Gemfile
|
98
|
+
- LICENSE.txt
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- html2js-rails.gemspec
|
102
|
+
- lib/html2js-rails.rb
|
103
|
+
- lib/html2js/config.rb
|
104
|
+
- lib/html2js/rails/engine.rb
|
105
|
+
- lib/html2js/rails/template_handler.rb
|
106
|
+
- lib/html2js/rails/version.rb
|
107
|
+
homepage: ''
|
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: 1.3.1
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.0.0
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: Compile AngularJS templates to Javascript files
|
131
|
+
test_files: []
|