pug-rails 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jade-rails/railtie.rb +22 -5
- data/lib/jade-rails/template.rb +21 -5
- data/lib/pug-rails/railtie.rb +22 -5
- data/lib/pug-rails/template.rb +21 -5
- data/pug-rails.gemspec +1 -2
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2391f26ad0a9641784adb7a692a7bc057d42db3
|
4
|
+
data.tar.gz: 3b8529acc4f579511a7371662b0f43d41475c822
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62bc6d6bd5882c022a7d2501f3325220b59e0f23c4881a6a57f0572d5d93f74197eb7eaa48149496082e32cfb8be443d2b0340e35e5c1413433ebc11a32f6925
|
7
|
+
data.tar.gz: a4226d6e29f3da4212c6b6821a05e1057757528c45997ca071c02d992ca2307e1b9f5f1929faa909e9e133a749d168b201ff32687852d8bde38aa2365bdb7ddf
|
data/lib/jade-rails/railtie.rb
CHANGED
@@ -5,12 +5,29 @@ module Jade
|
|
5
5
|
config.jade.pretty = Rails.env.development?
|
6
6
|
config.jade.compile_debug = Rails.env.development?
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def configure_assets(app)
|
9
|
+
if config.respond_to?(:assets) && config.assets.respond_to?(:configure)
|
10
|
+
# Rails 4.x
|
11
|
+
config.assets.configure { |env| yield(env) }
|
12
12
|
else
|
13
|
-
|
13
|
+
# Rails 3.2
|
14
|
+
yield(app.assets)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer 'sprockets.jade', group: :all, after: 'sprockets.environment' do |app|
|
19
|
+
configure_assets(app) do |env|
|
20
|
+
# Sprockets 2, 3, and 4
|
21
|
+
if env.respond_to?(:register_transformer)
|
22
|
+
env.register_mime_type 'text/x-jade', extensions: ['.jade']
|
23
|
+
env.register_transformer 'text/x-jade', 'application/javascript', Jade::SprocketsTransformer
|
24
|
+
end
|
25
|
+
|
26
|
+
if env.respond_to?(:register_engine)
|
27
|
+
args = ['.jade', Jade::SprocketsTransformer]
|
28
|
+
args << { mime_type: 'text/x-jade', silence_deprecation: true } if Sprockets::VERSION.start_with?('3')
|
29
|
+
env.register_engine(*args)
|
30
|
+
end
|
14
31
|
end
|
15
32
|
end
|
16
33
|
end
|
data/lib/jade-rails/template.rb
CHANGED
@@ -1,12 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'tilt'
|
3
2
|
module Jade
|
4
|
-
|
5
|
-
|
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
|
6
9
|
end
|
7
10
|
|
8
|
-
def
|
9
|
-
|
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)
|
10
26
|
end
|
11
27
|
end
|
12
28
|
end
|
data/lib/pug-rails/railtie.rb
CHANGED
@@ -5,12 +5,29 @@ module Pug
|
|
5
5
|
config.pug.pretty = Rails.env.development?
|
6
6
|
config.pug.compile_debug = Rails.env.development?
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def configure_assets(app)
|
9
|
+
if config.respond_to?(:assets) && config.assets.respond_to?(:configure)
|
10
|
+
# Rails 4.x
|
11
|
+
config.assets.configure { |env| yield(env) }
|
12
12
|
else
|
13
|
-
|
13
|
+
# Rails 3.2
|
14
|
+
yield(app.assets)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer 'sprockets.pug', group: :all, after: 'sprockets.environment' do |app|
|
19
|
+
configure_assets(app) do |env|
|
20
|
+
# Sprockets 2, 3, and 4
|
21
|
+
if env.respond_to?(:register_transformer)
|
22
|
+
env.register_mime_type 'text/x-pug', extensions: ['.pug']
|
23
|
+
env.register_transformer 'text/x-pug', 'application/javascript+function', Pug::SprocketsTransformer
|
24
|
+
end
|
25
|
+
|
26
|
+
if env.respond_to?(:register_engine)
|
27
|
+
args = ['.pug', Pug::SprocketsTransformer]
|
28
|
+
args << { mime_type: 'text/x-pug', silence_deprecation: true } if Sprockets::VERSION.start_with?('3')
|
29
|
+
env.register_engine(*args)
|
30
|
+
end
|
14
31
|
end
|
15
32
|
end
|
16
33
|
end
|
data/lib/pug-rails/template.rb
CHANGED
@@ -1,12 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'tilt'
|
3
2
|
module Pug
|
4
|
-
|
5
|
-
|
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
|
6
9
|
end
|
7
10
|
|
8
|
-
def
|
9
|
-
|
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)
|
10
26
|
end
|
11
27
|
end
|
12
28
|
end
|
data/pug-rails.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'pug-rails'
|
4
|
-
s.version = '2.0.
|
4
|
+
s.version = '2.0.2'
|
5
5
|
s.author = 'Yaroslav Konoplov'
|
6
6
|
s.email = 'eahome00@gmail.com'
|
7
7
|
s.summary = 'Pug/Jade template engine integration with Rails asset pipeline.'
|
@@ -15,5 +15,4 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.require_paths = ['lib']
|
16
16
|
|
17
17
|
s.add_dependency 'pug-ruby', '~> 1.0'
|
18
|
-
s.add_dependency 'tilt', '~> 2.0'
|
19
18
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Konoplov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pug-ruby
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: tilt
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2.0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2.0'
|
41
27
|
description: Pug/Jade template engine integration with Rails asset pipeline.
|
42
28
|
email: eahome00@gmail.com
|
43
29
|
executables: []
|