jekyll-tilt 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 81861ca0bec79dcd5b22bfec9334b672965033c9f0927185c8a836b09741cc3b
4
+ data.tar.gz: 8a41d463f036ef2e3c243077262c00daa484682f749e6f49db7dcf32388d8ea6
5
+ SHA512:
6
+ metadata.gz: cd25c507e869e43b804e51b38e7e34733aae164b4869008bf46b877608478064ed731237ba98da4a51da8a34c9d163d939bd8ff029229d26bef79284084ff770
7
+ data.tar.gz: 8a206c7560050244576a8e86eee1894ba1066b1a3cacc39d4542e04af87488ee3b661ad2496508d06f8fd13a8ac44311aac9f0e627536ffa615d27198b49022a
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2017 - 2018 - MIT License
3
+ # Source: https://github.com/envygeeks/devfiles
4
+ # Author: Jordon Bedwell
5
+ # Encoding: utf-8
6
+
7
+ source "https://rubygems.org"
8
+ gemspec
9
+
10
+ group :development do
11
+ gem "pry", require: false
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Anomaly
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,16 @@
1
+ # Jekyll Tilt
2
+
3
+ Jekyll Tilt is a template ***preprocessor*** for Jekyll.
4
+
5
+ ## How is it different?
6
+
7
+ The major difference between other processors and Jekyll Tilt is that we do not trust, or rely on Jekyll to do the bulk of our work. And we do the bulk of our work before Jekyll does it's work. That means we process your templates *before* Jekyll does it's processing, and then after we process, we replace the content that Jekyll expects to be content. This allows us to not only maintain a small code base, but to prevent common errors with other templating systems that integrate tightly with Jekyll.
8
+
9
+ ## Supported Engines
10
+
11
+ | Extension | Engine | Layouts | Pages | Default |
12
+ | --------- | ------ | ------- | ----- | ------- |
13
+ | .haml | Haml | ✔ | ✔ | ✔ |
14
+ | .erb | ERB | ✔ | ✔ | ✔ |
15
+ | .erubis | Erubis | ✔ | ✔ | ✗ |
16
+ | .sigil | Sigil | ✔ | ✔ | ✗ |
@@ -0,0 +1,42 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2017 - 2018 - MIT License
3
+ # Source: https://github.com/envygeeks/devfiles
4
+ # Author: Jordon Bedwell
5
+ # Encoding: utf-8
6
+
7
+ # --
8
+ # 🔖
9
+ # RSpec, MiniTest, Whatever.
10
+ # --
11
+ task default: [:spec]
12
+ task :spec do
13
+ exec "script/test"
14
+ end
15
+ # --
16
+ # 🔖
17
+ # RSpec, MiniTest, Whatever.
18
+ # --
19
+ task :test do
20
+ exec "script/test"
21
+ end
22
+ # --
23
+ # 🔖
24
+ # @see .rubocop.yml
25
+ # Rubocop.
26
+ # --
27
+ task :rubocop do
28
+ exec "script/lint"
29
+ end
30
+ # --
31
+ # 🔖
32
+ # @see .rubocop.yml
33
+ # Rubocop.
34
+ # --
35
+ task :lint do
36
+ exec "script/lint"
37
+ end
38
+
39
+ # --
40
+ Dir.glob("script/rake.d/*.rake").each do |v|
41
+ load v
42
+ end
@@ -0,0 +1,5 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2018 - Apache 2.0 License
3
+ # Encoding: utf-8
4
+
5
+ require "jekyll/tilt"
@@ -0,0 +1,53 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2018 - Apache 2.0 License
3
+ # Encoding: utf-8
4
+
5
+ require "jekyll"
6
+ require "pathutil"
7
+ require "jekyll/tilt/processor"
8
+ require "jekyll/tilt/include_patch"
9
+ require "jekyll/tilt/version"
10
+ require "tilt"
11
+
12
+ module Jekyll
13
+ module Tilt
14
+ Upstream = ::Tilt
15
+
16
+ # --
17
+ # Register a hook
18
+ # @return [nil]
19
+ # --
20
+ def self.setup!
21
+ Jekyll::Hooks.register :site, :pre_render do |s, _|
22
+ convert_p!(s)
23
+ convert_l!(s)
24
+ end
25
+ end
26
+
27
+ # --
28
+ # Convert layouts
29
+ # @return [nil]
30
+ # --
31
+ def self.convert_l!(site)
32
+ site.layouts.each_value do |v|
33
+ v.content = Processor.run_for(v.content, {
34
+ ext: v.ext,
35
+ })
36
+ end
37
+ end
38
+
39
+ # --
40
+ # Convert pages
41
+ # @return [nil]
42
+ # --
43
+ def self.convert_p!(site)
44
+ site.pages.each do |v|
45
+ v.content = Processor.run_for(v.content, {
46
+ ext: v.ext,
47
+ })
48
+ end
49
+ end
50
+
51
+ setup!
52
+ end
53
+ end
@@ -0,0 +1,17 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2018 - Apache 2.0 License
3
+ # Encoding: utf-8
4
+
5
+ module Jekyll
6
+ module Tags
7
+ class IncludeTag
8
+ def read_file(file, ctx)
9
+ pth = Pathutil.new(file)
10
+ out = pth.read(file_read_opts(ctx))
11
+ Tilt::Processor.run_for(out, {
12
+ ext: pth.extname,
13
+ })
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,64 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2018 - Apache 2.0 License
3
+ # Encoding: utf-8
4
+
5
+ module Jekyll
6
+ module Tilt
7
+ class Processor
8
+ @inherited = []
9
+
10
+ # --
11
+ # Allows us to track inherited
12
+ # @return [Array<Object>]
13
+ # --
14
+ def self.inherited(const = nil)
15
+ return @inherited unless const
16
+ @inherited |= [
17
+ const,
18
+ ]
19
+ end
20
+
21
+ # --
22
+ # Allows you to set an extension
23
+ # @note We will create the Jekyll shims
24
+ # @return [nil]
25
+ # --
26
+ def self.for_ext(ext)
27
+ ext = ext.gsub(%r!^\.!, "")
28
+ k = const_set(:Converter, Class.new(Converter))
29
+ define_singleton_method(:matches) { |e| e == ext || e == ".#{ext}" }
30
+ k.define_method(:matches) { |e| e == ext || e == ".#{ext}" }
31
+ k.define_method(:output_ext) { |*| ".html" }
32
+ k.define_method(:convert) { |c| c }
33
+ end
34
+
35
+ # --
36
+ # Finds the const that handles an ext
37
+ # @return [Array<Object>]
38
+ # --
39
+ def self.find_for(ext)
40
+ inherited.select do |v|
41
+ v.matches(ext)
42
+ end
43
+ end
44
+
45
+ # --
46
+ # Runs the consts on the content
47
+ # @param out [String] the content to output
48
+ # @return [String]
49
+ # --
50
+ def self.run_for(out, ext:)
51
+ find_for(ext).each do |v|
52
+ out = v.run_for(out)
53
+ end
54
+
55
+ out
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ require "jekyll/tilt/processors/erb"
62
+ require "jekyll/tilt/processors/erubis"
63
+ require "jekyll/tilt/processors/sigil"
64
+ require "jekyll/tilt/processors/haml"
@@ -0,0 +1,17 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2018 - Apache 2.0 License
3
+ # Encoding: utf-8
4
+
5
+ module Jekyll
6
+ module Tilt
7
+ module Processors
8
+ class ERB < Processor
9
+ for_ext "erb"
10
+ def self.run_for(content, **vars)
11
+ Upstream::ERBTemplate.new { content }
12
+ .render(**vars)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2018 - Apache 2.0 License
3
+ # Encoding: utf-8
4
+
5
+ module Jekyll
6
+ module Tilt
7
+ module Processors
8
+ class Erubis < Processor
9
+ for_ext "erubis"
10
+ def self.run_for(content, **vars)
11
+ Upstream::ErubisTemplate.new { content }
12
+ .render(**vars)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2018 - Apache 2.0 License
3
+ # Encoding: utf-8
4
+
5
+ module Jekyll
6
+ module Tilt
7
+ module Processors
8
+ class Haml < Processor
9
+ for_ext "haml"
10
+ def self.run_for(content, **vars)
11
+ Upstream::HamlTemplate.new { content }
12
+ .render(**vars)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2018 - Apache 2.0 License
3
+ # Encoding: utf-8
4
+
5
+ module Jekyll
6
+ module Tilt
7
+ module Processors
8
+ class Sigil < Processor
9
+ for_ext "sigil"
10
+ def self.run_for(content, **vars)
11
+ Upstream::SigilTemplate.new { content }
12
+ .render(**vars)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2018 - Apache 2.0 License
3
+ # Encoding: utf-8
4
+
5
+ module Jekyll
6
+ module Tilt
7
+ VERSION = "1.0.0"
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,197 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-tilt
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jordon Bedwell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jekyll-assets
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: luna-rspec-formatters
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.8'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.8'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: '0.52'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: '0.52'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pathutil
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.16'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.16'
111
+ - !ruby/object:Gem::Dependency
112
+ name: jekyll
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.5'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.5'
125
+ - !ruby/object:Gem::Dependency
126
+ name: haml
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '5.0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '5.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: tilt
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.0'
153
+ description:
154
+ email:
155
+ - jordon@envygeeks.io
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - Gemfile
161
+ - LICENSE
162
+ - README.md
163
+ - Rakefile
164
+ - lib/jekyll-tilt.rb
165
+ - lib/jekyll/tilt.rb
166
+ - lib/jekyll/tilt/include_patch.rb
167
+ - lib/jekyll/tilt/processor.rb
168
+ - lib/jekyll/tilt/processors/erb.rb
169
+ - lib/jekyll/tilt/processors/erubis.rb
170
+ - lib/jekyll/tilt/processors/haml.rb
171
+ - lib/jekyll/tilt/processors/sigil.rb
172
+ - lib/jekyll/tilt/version.rb
173
+ homepage: http://github.com/anomaly/jekyll-tilt/
174
+ licenses:
175
+ - Apache-2.0
176
+ metadata: {}
177
+ post_install_message:
178
+ rdoc_options: []
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: 2.3.0
186
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ requirements: []
192
+ rubyforge_project:
193
+ rubygems_version: 2.7.6
194
+ signing_key:
195
+ specification_version: 4
196
+ summary: Preprocess your templates with Tilt
197
+ test_files: []