pug-rails 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +23 -0
- data/Appraisals +18 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +138 -0
- data/README.md +21 -3
- data/Rakefile +11 -0
- data/gemfiles/rails_3.gemfile +9 -0
- data/gemfiles/rails_3.gemfile.lock +124 -0
- data/gemfiles/rails_4_with_sprockets_2.gemfile +9 -0
- data/gemfiles/rails_4_with_sprockets_2.gemfile.lock +138 -0
- data/gemfiles/rails_4_with_sprockets_3.gemfile +9 -0
- data/gemfiles/rails_4_with_sprockets_3.gemfile.lock +138 -0
- data/gemfiles/rails_5.gemfile +9 -0
- data/gemfiles/rails_5.gemfile.lock +142 -0
- data/lib/jade-rails/railtie.rb +32 -16
- data/lib/jade-rails/sprockets/transformer.rb +32 -0
- data/lib/pug-rails.rb +8 -2
- data/lib/pug-rails/railtie.rb +32 -16
- data/lib/pug-rails/sprockets/transformer.rb +32 -0
- data/pug-rails.gemspec +8 -2
- data/test/fixtures/javascripts/application.js +2 -0
- data/test/fixtures/javascripts/templates/jade.jst.jade +1 -0
- data/test/fixtures/javascripts/templates/pug.jst.pug +1 -0
- data/test/test-pug-rails.rb +105 -0
- metadata +102 -5
- data/lib/jade-rails/template.rb +0 -28
- data/lib/pug-rails/template.rb +0 -28
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Pug
|
5
|
+
module Sprockets
|
6
|
+
# Sprockets 2, 3 & 4 interface
|
7
|
+
# https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#registering-all-versions-of-sprockets-in-processors
|
8
|
+
class Transformer
|
9
|
+
def initialize(filename, &block)
|
10
|
+
@filename = filename
|
11
|
+
@source = block.call
|
12
|
+
end
|
13
|
+
|
14
|
+
def render(context, _)
|
15
|
+
self.class.run(@filename, @source, context)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.run(filename, source, context)
|
19
|
+
Pug.compile(source, filename: filename, client: true)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.call(input)
|
23
|
+
filename = input[:filename]
|
24
|
+
source = input[:data]
|
25
|
+
context = input[:environment].context_class.new(input)
|
26
|
+
|
27
|
+
result = run(filename, source, context)
|
28
|
+
context.metadata.merge(data: result)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/pug-rails.gemspec
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
# frozen_string_literal: true
|
3
|
+
|
2
4
|
Gem::Specification.new do |s|
|
3
5
|
s.name = 'pug-rails'
|
4
|
-
s.version = '2.0.
|
6
|
+
s.version = '2.0.3'
|
5
7
|
s.author = 'Yaroslav Konoplov'
|
6
8
|
s.email = 'eahome00@gmail.com'
|
7
9
|
s.summary = 'Pug/Jade template engine integration with Rails asset pipeline.'
|
@@ -9,10 +11,14 @@ Gem::Specification.new do |s|
|
|
9
11
|
s.homepage = 'https://github.com/yivo/pug-rails'
|
10
12
|
s.license = 'MIT'
|
11
13
|
|
12
|
-
s.executables = `git ls-files -z -- bin/*`.split("\x0").map{ |f| File.basename(f) }
|
13
14
|
s.files = `git ls-files -z`.split("\x0")
|
14
15
|
s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
|
15
16
|
s.require_paths = ['lib']
|
16
17
|
|
17
18
|
s.add_dependency 'pug-ruby', '~> 1.0'
|
19
|
+
s.add_development_dependency 'bundler', '~> 1.7'
|
20
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
21
|
+
s.add_development_dependency 'appraisal', '~> 2.1'
|
22
|
+
s.add_development_dependency 'test-unit', '~> 3.1'
|
23
|
+
s.add_development_dependency 'nokogiri', '~> 1.6', '< 1.7'
|
18
24
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
div Hello, Jade!
|
@@ -0,0 +1 @@
|
|
1
|
+
div Hello, Pug!
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'rails'
|
5
|
+
require 'sprockets/railtie'
|
6
|
+
require 'pug-rails'
|
7
|
+
require 'test/unit'
|
8
|
+
require 'fileutils'
|
9
|
+
|
10
|
+
class PugRailsTest < Test::Unit::TestCase
|
11
|
+
def test_registration
|
12
|
+
app = create_rails_application
|
13
|
+
app.initialize!
|
14
|
+
|
15
|
+
if app.assets.respond_to?(:transformers)
|
16
|
+
assert app.assets.transformers.fetch('text/x-pug').fetch('application/javascript+function') == Pug::Sprockets::Transformer
|
17
|
+
assert app.assets.transformers.fetch('text/x-jade').fetch('application/javascript+function') == Jade::Sprockets::Transformer
|
18
|
+
end
|
19
|
+
|
20
|
+
if app.assets.respond_to?(:engines)
|
21
|
+
assert app.assets.engines.fetch('.pug') == Pug::Sprockets::Transformer
|
22
|
+
assert app.assets.engines.fetch('.jade') == Jade::Sprockets::Transformer
|
23
|
+
end
|
24
|
+
|
25
|
+
assert app.assets.paths.include?(File.expand_path('../../vendor/assets/javascripts', __FILE__))
|
26
|
+
assert_includes app.config.assets.precompile, 'pug/runtime.js'
|
27
|
+
assert_includes app.config.assets.precompile, 'jade/runtime.js'
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_compilation
|
31
|
+
app = create_rails_application
|
32
|
+
app.initialize!
|
33
|
+
task = create_sprockets_task(app)
|
34
|
+
task.instance_exec { manifest.compile(assets) }
|
35
|
+
|
36
|
+
expected = <<-JAVASCRIPT.squish
|
37
|
+
(function() { this.JST || (this.JST = {}); this.JST["templates/jade"] = (function(jade) { function template(locals) {
|
38
|
+
var buf = [];
|
39
|
+
var jade_mixins = {};
|
40
|
+
var jade_interp;
|
41
|
+
|
42
|
+
buf.push("<div>Hello, Jade!</div>");;return buf.join("");
|
43
|
+
}; return template; }).call(this, jade);;
|
44
|
+
}).call(this);
|
45
|
+
(function() { this.JST || (this.JST = {}); this.JST["templates/pug"] = (function() { function template(locals) {var pug_html = "", pug_mixins = {}, pug_interp;pug_html = pug_html + "\\u003Cdiv\\u003EHello, Pug!\\u003C\\u002Fdiv\\u003E";;return pug_html;}; return template; }).call(this);;
|
46
|
+
}).call(this);
|
47
|
+
JAVASCRIPT
|
48
|
+
assert_equal expected, app.assets['application.js'].to_s.squish
|
49
|
+
end
|
50
|
+
|
51
|
+
def setup
|
52
|
+
super
|
53
|
+
clear_tmp
|
54
|
+
clear_logs
|
55
|
+
end
|
56
|
+
|
57
|
+
def teardown
|
58
|
+
super
|
59
|
+
clear_tmp
|
60
|
+
if defined?(Rails) && Rails.respond_to?(:application=)
|
61
|
+
Rails.application = nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def create_rails_application
|
67
|
+
Class.new(Rails::Application) do
|
68
|
+
config.eager_load = false
|
69
|
+
config.assets.enabled = true
|
70
|
+
config.assets.gzip = false
|
71
|
+
config.assets.paths = [Rails.root.join('test/fixtures/javascripts').to_s]
|
72
|
+
config.assets.precompile = %w( application.js )
|
73
|
+
config.paths['public'] = [Rails.root.join('tmp').to_s]
|
74
|
+
config.active_support.deprecation = :stderr
|
75
|
+
config.pug.compile_debug = false
|
76
|
+
config.jade.compile_debug = false
|
77
|
+
config.pug.pretty = false
|
78
|
+
config.jade.pretty = false
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def create_sprockets_task(app)
|
83
|
+
require 'sprockets/version' # Fix for sprockets 2.x
|
84
|
+
|
85
|
+
if Sprockets::VERSION.start_with?('2')
|
86
|
+
require 'rake/sprocketstask'
|
87
|
+
Rake::SprocketsTask.new do |t|
|
88
|
+
t.environment = app.assets
|
89
|
+
t.output = "#{app.config.paths['public'][0]}#{app.config.assets.prefix}"
|
90
|
+
t.assets = app.config.assets.precompile
|
91
|
+
end
|
92
|
+
else
|
93
|
+
require 'sprockets/rails/task'
|
94
|
+
Sprockets::Rails::Task.new(app)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def clear_tmp
|
99
|
+
FileUtils.rm_rf(File.expand_path('../../tmp', __FILE__))
|
100
|
+
end
|
101
|
+
|
102
|
+
def clear_logs
|
103
|
+
FileUtils.rm_rf(File.expand_path('../../log', __FILE__))
|
104
|
+
end
|
105
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pug-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Konoplov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pug-ruby
|
@@ -24,6 +24,82 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: appraisal
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: nokogiri
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.6'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '1.7'
|
93
|
+
type: :development
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '1.6'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '1.7'
|
27
103
|
description: Pug/Jade template engine integration with Rails asset pipeline.
|
28
104
|
email: eahome00@gmail.com
|
29
105
|
executables: []
|
@@ -31,13 +107,30 @@ extensions: []
|
|
31
107
|
extra_rdoc_files: []
|
32
108
|
files:
|
33
109
|
- ".gitignore"
|
110
|
+
- ".travis.yml"
|
111
|
+
- Appraisals
|
112
|
+
- Gemfile
|
113
|
+
- Gemfile.lock
|
34
114
|
- README.md
|
115
|
+
- Rakefile
|
116
|
+
- gemfiles/rails_3.gemfile
|
117
|
+
- gemfiles/rails_3.gemfile.lock
|
118
|
+
- gemfiles/rails_4_with_sprockets_2.gemfile
|
119
|
+
- gemfiles/rails_4_with_sprockets_2.gemfile.lock
|
120
|
+
- gemfiles/rails_4_with_sprockets_3.gemfile
|
121
|
+
- gemfiles/rails_4_with_sprockets_3.gemfile.lock
|
122
|
+
- gemfiles/rails_5.gemfile
|
123
|
+
- gemfiles/rails_5.gemfile.lock
|
35
124
|
- lib/jade-rails/railtie.rb
|
36
|
-
- lib/jade-rails/
|
125
|
+
- lib/jade-rails/sprockets/transformer.rb
|
37
126
|
- lib/pug-rails.rb
|
38
127
|
- lib/pug-rails/railtie.rb
|
39
|
-
- lib/pug-rails/
|
128
|
+
- lib/pug-rails/sprockets/transformer.rb
|
40
129
|
- pug-rails.gemspec
|
130
|
+
- test/fixtures/javascripts/application.js
|
131
|
+
- test/fixtures/javascripts/templates/jade.jst.jade
|
132
|
+
- test/fixtures/javascripts/templates/pug.jst.pug
|
133
|
+
- test/test-pug-rails.rb
|
41
134
|
- vendor/assets/javascripts/jade/LICENCE
|
42
135
|
- vendor/assets/javascripts/jade/runtime.js
|
43
136
|
- vendor/assets/javascripts/pug/LICENCE
|
@@ -66,4 +159,8 @@ rubygems_version: 2.5.1
|
|
66
159
|
signing_key:
|
67
160
|
specification_version: 4
|
68
161
|
summary: Pug/Jade template engine integration with Rails asset pipeline.
|
69
|
-
test_files:
|
162
|
+
test_files:
|
163
|
+
- test/fixtures/javascripts/application.js
|
164
|
+
- test/fixtures/javascripts/templates/jade.jst.jade
|
165
|
+
- test/fixtures/javascripts/templates/pug.jst.pug
|
166
|
+
- test/test-pug-rails.rb
|
data/lib/jade-rails/template.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Jade
|
3
|
-
# Sprockets 2, 3 & 4 interface
|
4
|
-
# https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#registering-all-versions-of-sprockets-in-processors
|
5
|
-
class SprocketsTransformer
|
6
|
-
def initialize(filename, &block)
|
7
|
-
@filename = filename
|
8
|
-
@source = block.call
|
9
|
-
end
|
10
|
-
|
11
|
-
def render(context, empty_hash_wtf)
|
12
|
-
self.class.run(@filename, @source, context)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.run(filename, source, context)
|
16
|
-
Jade.compile(source, filename: filename, client: true)
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.call(input)
|
20
|
-
filename = input[:filename]
|
21
|
-
source = input[:data]
|
22
|
-
context = input[:environment].context_class.new(input)
|
23
|
-
|
24
|
-
result = run(filename, source, context)
|
25
|
-
context.metadata.merge(data: result)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/pug-rails/template.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Pug
|
3
|
-
# Sprockets 2, 3 & 4 interface
|
4
|
-
# https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#registering-all-versions-of-sprockets-in-processors
|
5
|
-
class SprocketsTransformer
|
6
|
-
def initialize(filename, &block)
|
7
|
-
@filename = filename
|
8
|
-
@source = block.call
|
9
|
-
end
|
10
|
-
|
11
|
-
def render(context, empty_hash_wtf)
|
12
|
-
self.class.run(@filename, @source, context)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.run(filename, source, context)
|
16
|
-
Pug.compile(source, filename: filename, client: true)
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.call(input)
|
20
|
-
filename = input[:filename]
|
21
|
-
source = input[:data]
|
22
|
-
context = input[:environment].context_class.new(input)
|
23
|
-
|
24
|
-
result = run(filename, source, context)
|
25
|
-
context.metadata.merge(data: result)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|