jekyll-haml 0.1.5 → 1.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 76c8f4b342f2983cca116706d6b345cba5dc978d
4
- data.tar.gz: cf711cf86cf8b85b62303be1237950cffdff0f10
2
+ SHA256:
3
+ metadata.gz: e9051303083d86acc94dad50b1c0df7ad02b128b02ff750a0c37922456cc6ded
4
+ data.tar.gz: 112427d6d32930dc72aea85325bb80138c2f16cf528964eb9c7c0b0c75082cb8
5
5
  SHA512:
6
- metadata.gz: ae4f18d98d23ef3ef5e27e9dbce229fe9beca3f73ac80b618a94640977444f70cac5d9acef44802b69edd2e6b32409933aacbb5a41440641d3eb14f6b4b84c19
7
- data.tar.gz: 0e672c7062712676d21be4ee5517ae34f9975a7d7c7095a7da4748b22d7e8a0f8ed10040d5a212e2c4f0a40c425e79355800e5a0c2130dd6ece8668f0c471d15
6
+ metadata.gz: a1cf72bb0ee0a22a2882aae0e3594200c41f452ff2e69b715df802bdb0ddeadc6d280ee07c72aef680659efc03b1e6f10d0e3f379f624dea8bcc25e272cdfffb
7
+ data.tar.gz: cd255a43ad7b5fb1f8a6c6db615b931429ca4fb745b1491eef495d3be66140e1629da635bc958281341e17f2261162ff51528a3f4d9ca694a99838320eb4d566
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 1.0.0 2024-05-15
2
+ ### breaking changes in order to work with jekyll ~> 4.0
3
+ * rework of haml liquid tag implementation - ([@mfaughn][])
4
+ * change Coverter._renderer to Coverter.renderer in convertible.rb - ([@mfaughn][])
5
+ * update dependencies in gemspec - ([@mfaughn][])
6
+
7
+ ## 0.1.6 2017-11-10
8
+ ### minor enhancements
9
+ * removes newlines from `{% haml %}` includes - ([@pedrozath][])
10
+
1
11
  ## 0.1.5 2016-12-30
2
12
  ### minor enhancements
3
13
  * Fixed an error with Jekyll 3.3.0 and later https://github.com/samvincent/jekyll-haml/issues/19
data/jekyll-haml.gemspec CHANGED
@@ -17,6 +17,6 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_runtime_dependency 'jekyll', '>= 3.3.0'
21
- gem.add_runtime_dependency 'haml', '>= 3.0.0'
20
+ gem.add_runtime_dependency 'jekyll', '~> 4.0'
21
+ gem.add_runtime_dependency 'haml', '~> 5.0'
22
22
  end
@@ -9,7 +9,7 @@ module Jekyll
9
9
  end
10
10
 
11
11
  def transform
12
- _renderer.convert(content)
12
+ renderer.convert(content)
13
13
  end
14
14
 
15
15
  def extname
@@ -1,52 +1,59 @@
1
1
  require 'haml'
2
2
 
3
3
  module Jekyll
4
-
5
- class HamlPartialTag < Liquid::Tag
6
- def initialize(tag_name, file, tokens)
7
- super
8
- @file = file.strip
9
- end
10
-
11
- def render(context)
12
- includes_dir = File.join(context.registers[:site].source, '_includes')
13
-
14
- if File.symlink?(includes_dir)
15
- return "Includes directory '#{includes_dir}' cannot be a symlink"
4
+ module Tags
5
+ class HamlIncludeTag < IncludeTag
6
+ def initialize(tag_name, file, tokens)
7
+ super
8
+ @file = file.strip
16
9
  end
10
+
11
+ def load_cached_partial(path, context)
12
+ context.registers[:cached_partials] ||= {}
13
+ cached_partial = context.registers[:cached_partials]
17
14
 
18
- if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
19
- return "Include file '#{@file}' contains invalid characters or sequences"
20
- end
21
-
22
- return "File must have \".haml\" extension" if @file !~ /\.haml$/
23
-
24
- Dir.chdir(includes_dir) do
25
- choices = Dir['**/*'].reject { |x| File.symlink?(x) }
26
- if choices.include?(@file)
27
- source = File.read(@file)
28
- conversion = ::Haml::Engine.new(source).render
29
- partial = Liquid::Template.parse(conversion)
15
+ if cached_partial.key?(path)
16
+ cached_partial[path]
17
+ else
18
+ html = ::Haml::Engine.new(File.read(path)).render.delete("\n")
19
+ unparsed_file = context.registers[:site]
20
+ .liquid_renderer
21
+ .file(path)
30
22
  begin
31
- return partial.render!(context)
23
+ cached_partial[path] = unparsed_file.parse(html)
32
24
  rescue => e
33
- puts "Liquid Exception: #{e.message} in #{self.data["layout"]}"
34
- e.backtrace.each do |backtrace|
35
- puts backtrace
36
- end
37
- abort("Build Failed")
25
+ e.template_name = path
26
+ e.markup_context = "haml " if e.markup_context.nil?
27
+ raise e
38
28
  end
29
+ end
30
+ end
39
31
 
40
- context.stack do
41
- return partial.render(context)
32
+ def render(context)
33
+ if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
34
+ return "Include file '#{@file}' contains invalid characters or sequences"
35
+ end
36
+ return "File must have \".haml\" extension" if @file !~ /\.haml$/
37
+
38
+ site = context.registers[:site]
39
+ path = locate_include_file(context, @file, site.safe)
40
+ return unless path
41
+ add_include_to_dependency(site, path, context)
42
+
43
+ partial = load_cached_partial(path, context)
44
+
45
+ context.stack do
46
+ begin
47
+ partial.render!(context)
48
+ rescue Liquid::Error => e
49
+ e.template_name = path
50
+ e.markup_context = "included " if e.markup_context.nil?
51
+ raise e
42
52
  end
43
- else
44
- "Included file '#{@file}' not found in _includes directory"
45
53
  end
46
54
  end
47
- end
48
- end
49
-
50
- end
51
55
 
52
- Liquid::Template.register_tag('haml', Jekyll::HamlPartialTag)
56
+ end # HamlIncludeTag
57
+ end # Tags
58
+ end # Jekyll
59
+ Liquid::Template.register_tag('haml', Jekyll::Tags::HamlIncludeTag)
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Haml
3
- VERSION = '0.1.5'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
  end
5
5
  end
data/lib/jekyll-haml.rb CHANGED
@@ -5,20 +5,22 @@ require "jekyll-haml/tags/haml_partial"
5
5
  require "jekyll-haml/ext/convertible"
6
6
 
7
7
  module Jekyll
8
- class HamlConverter < Converter
9
- safe true
10
- priority :low
8
+ module Converters
9
+ class Haml < Converter
10
+ safe true
11
+ priority :low
11
12
 
12
- def matches(ext)
13
- ext =~ /haml/i
14
- end
13
+ def matches(_ext)
14
+ _ext =~ /haml/i
15
+ end
15
16
 
16
- def output_ext(ext)
17
- ".html"
18
- end
17
+ def output_ext(ext)
18
+ ".html"
19
+ end
19
20
 
20
- def convert(content)
21
- ::Haml::Engine.new(content).render
21
+ def convert(content)
22
+ ::Haml::Engine.new(content).render
23
+ end
22
24
  end
23
25
  end
24
- end
26
+ end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Vincent
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-04 00:00:00.000000000 Z
11
+ date: 2024-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.3.0
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.3.0
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: haml
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.0.0
33
+ version: '5.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.0.0
40
+ version: '5.0'
41
41
  description: HAML html converter for Jekyll
42
42
  email:
43
43
  - sam.vincent@mac.com
@@ -59,7 +59,7 @@ files:
59
59
  homepage: ''
60
60
  licenses: []
61
61
  metadata: {}
62
- post_install_message:
62
+ post_install_message:
63
63
  rdoc_options: []
64
64
  require_paths:
65
65
  - lib
@@ -74,9 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.4.6
79
- signing_key:
77
+ rubygems_version: 3.5.16
78
+ signing_key:
80
79
  specification_version: 4
81
80
  summary: Convert HAML files to standard HTML files as part of your Jekyll build.
82
81
  test_files: []