jekyll-haml-markup 0.1.3 → 0.1.5

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
2
  SHA1:
3
- metadata.gz: ffe7f40f363076b9072ea42681b637314ec63601
4
- data.tar.gz: 62e5c1c47e6e76ce2dd69380ef4169ecf03c685c
3
+ metadata.gz: 821c7c0980785943787df8b85194fe5b9f8823fa
4
+ data.tar.gz: c43cb3af2ecb83ba4cb4d487a43bb26101fbedd0
5
5
  SHA512:
6
- metadata.gz: 9b9e757eee1034eff6500a89d408c2085bdcde03cda0c8f0cf82eb5ec320c40e28cb62244485bb77c83ffff61d9f8c3d0da46e45c992b6817d1de3f6b1ec64e2
7
- data.tar.gz: 13e1a4c26b4ef0faedd93b0da7e8eae4915855545bd0f3617f727d7dedb7cd811b14a692cb802a4e2d13463176a3faa433472aaaf36baa6eb8c18856bc49addd
6
+ metadata.gz: c3015ac642fe044e4d6cec1a10f0839b09a15039a76cda73fe3504895bb951db4b7f78f5c8c2725d89580214e123ee43f3fa042ce865d340dfec3c7a374fceb5
7
+ data.tar.gz: 8fde2e4f7de96bd7cf2102de808a0a8ac36cc24f5469dc6914bcb33fd39afbf2b0d925b0e69014dded705e97e49c9734f31ef0c48aeea386317463f9ae217785
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in jekyll-haml-markup.gemspec
6
6
  gemspec
data/Gemfile.lock CHANGED
@@ -1,29 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-haml-markup (0.1.3)
5
- haml (~> 4)
6
- jekyll (~> 3.0)
4
+ jekyll-haml-markup (0.1.5)
5
+ haml (~> 5.0, >= 5.0.0)
6
+ jekyll (>= 3.0, < 5.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.5.2)
12
- public_suffix (>= 2.0.2, < 4.0)
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ast (2.4.0)
13
14
  colorator (1.1.0)
14
- concurrent-ruby (1.0.5)
15
+ concurrent-ruby (1.1.5)
15
16
  em-websocket (0.5.1)
16
17
  eventmachine (>= 0.12.9)
17
18
  http_parser.rb (~> 0.6.0)
18
19
  eventmachine (1.2.7)
19
- ffi (1.9.25)
20
+ ffi (1.11.2)
20
21
  forwardable-extended (2.6.0)
21
- haml (4.0.7)
22
+ haml (5.1.2)
23
+ temple (>= 0.8.0)
22
24
  tilt
23
25
  http_parser.rb (0.6.0)
24
26
  i18n (0.9.5)
25
27
  concurrent-ruby (~> 1.0)
26
- jekyll (3.8.4)
28
+ jaro_winkler (1.5.4)
29
+ jekyll (3.8.6)
27
30
  addressable (~> 2.4)
28
31
  colorator (~> 1.0)
29
32
  em-websocket (~> 0.5)
@@ -41,7 +44,7 @@ GEM
41
44
  jekyll-watch (2.0.0)
42
45
  listen (~> 3.0)
43
46
  kramdown (1.17.0)
44
- liquid (4.0.0)
47
+ liquid (4.0.3)
45
48
  listen (3.0.8)
46
49
  rb-fsevent (~> 0.9, >= 0.9.4)
47
50
  rb-inotify (~> 0.9, >= 0.9.7)
@@ -50,21 +53,37 @@ GEM
50
53
  minitest (5.11.3)
51
54
  nokogiri (1.8.2)
52
55
  mini_portile2 (~> 2.3.0)
53
- pathutil (0.16.1)
56
+ parallel (1.13.0)
57
+ parser (2.6.5.0)
58
+ ast (~> 2.4.0)
59
+ pathutil (0.16.2)
54
60
  forwardable-extended (~> 2.6)
55
- public_suffix (3.0.3)
61
+ powerpack (0.1.2)
62
+ public_suffix (3.1.1)
63
+ rainbow (3.0.0)
56
64
  rake (10.5.0)
57
65
  rb-fsevent (0.10.3)
58
66
  rb-inotify (0.9.10)
59
67
  ffi (>= 0.5.0, < 2)
60
- rouge (3.2.1)
61
- safe_yaml (1.0.4)
62
- sass (3.6.0)
68
+ rouge (3.13.0)
69
+ rubocop (0.57.2)
70
+ jaro_winkler (~> 1.5.1)
71
+ parallel (~> 1.10)
72
+ parser (>= 2.5)
73
+ powerpack (~> 0.1)
74
+ rainbow (>= 2.2.2, < 4.0)
75
+ ruby-progressbar (~> 1.7)
76
+ unicode-display_width (~> 1.0, >= 1.0.1)
77
+ ruby-progressbar (1.10.1)
78
+ safe_yaml (1.0.5)
79
+ sass (3.7.4)
63
80
  sass-listen (~> 4.0.0)
64
81
  sass-listen (4.0.0)
65
82
  rb-fsevent (~> 0.9, >= 0.9.4)
66
83
  rb-inotify (~> 0.9, >= 0.9.7)
67
- tilt (2.0.8)
84
+ temple (0.8.2)
85
+ tilt (2.0.10)
86
+ unicode-display_width (1.6.0)
68
87
 
69
88
  PLATFORMS
70
89
  ruby
@@ -75,6 +94,7 @@ DEPENDENCIES
75
94
  minitest (~> 5.0)
76
95
  nokogiri (~> 1.6, >= 1.6.8)
77
96
  rake (~> 10.0)
97
+ rubocop (~> 0.57, >= 0.57.2)
78
98
 
79
99
  BUNDLED WITH
80
- 1.16.1
100
+ 1.17.3
data/README.md CHANGED
@@ -1,12 +1,10 @@
1
1
  # Jekyll Haml Markup
2
2
 
3
- [Jekyll](https://jekyllrb.com) plugin that enables [Haml](http://haml.info) as a markup option for layouts and partials.
4
-
5
- **Note**: This gem overwrites the `include` jekyll tag.
3
+ [Jekyll](https://jekyllrb.com) plugin that enables [Haml](http://haml.info) as a markup option for layouts, partials, and pages.
6
4
 
7
5
  ## Installation
8
6
 
9
- Add it to your Gemfile:
7
+ Add to your Gemfile:
10
8
 
11
9
  ```ruby
12
10
  gem 'jekyll-haml-markup', group: :jekyll_plugins
@@ -14,34 +12,14 @@ gem 'jekyll-haml-markup', group: :jekyll_plugins
14
12
 
15
13
  ## Usage
16
14
 
17
- You just need to save your layout or template with extension `.haml`, replacing any other extension.
18
-
19
- The layout haml markup is rendered with hooks before the [Liquid](http://shopify.github.io/liquid/) render phase and modify version of the `include` tag is in charge of the partials.
20
-
21
- ```haml
22
- !!!
23
- %html
24
- %head
25
- %title Fake title
26
- %link{href: "{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}", rel: "stylesheet", type: 'text/css'}
27
- %link(href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}" rel="stylesheet" type='text/css')
28
- %body
29
- %header
30
- {% include header.haml %}
31
- %main
32
- {{ content }}
33
- %footer
34
- {% include footer.html %}
35
- %script{src: "{{ '/assets/javascript/script.css?v=' | append: site.github.build_revision | relative_url }}"}
36
- ```
37
-
38
- Front-matter headers are not working on partials.
15
+ Name your layouts, partials, and pages with the `.haml` extension. This plugin intercepts the default `include` and compile your Haml template to HTML.
39
16
 
40
17
  ## Development
18
+ This gem uses a hook for Haml layouts compiling, modifies the `include` tag, and add a Haml converter.
41
19
 
42
- I started this gem because I couldn't make work the gem [jekyll-haml](https://github.com/samvincent/jekyll-haml).
20
+ There are lots of border cases that have to be tested before production use.
43
21
 
44
- At this moment, this gem just works overriding [Jekyll](https://github.com/jekyll/jekyll) classes and methods. It's not a stable option and it has to be reviewed. If you want to help, just email me.
22
+ I started this gem because I couldn't make work the [jekyll-haml](https://github.com/samvincent/jekyll-haml) gem, which seems inactive.
45
23
 
46
24
  ## Contributing
47
25
 
@@ -49,8 +27,8 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/afaund
49
27
 
50
28
  ## License
51
29
 
52
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
30
+ The gem is available as open-source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
53
31
 
54
32
  ## Code of Conduct
55
33
 
56
- Everyone interacting in the Jekyll::Haml::Markup project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/jekyll-haml-markup/blob/master/CODE_OF_CONDUCT.md).
34
+ Everyone interacting in the Jekyll::Haml::Markup project’s codebases, issue trackers, chat rooms, and mailing lists are expected to follow the [code of conduct](https://github.com/[USERNAME]/jekyll-haml-markup/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
8
  end
9
9
 
10
- task :default => :test
10
+ task default: :test
@@ -1,33 +1,34 @@
1
-
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'jekyll/haml/markup/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "jekyll-haml-markup"
6
+ spec.name = 'jekyll-haml-markup'
8
7
  spec.version = Jekyll::Haml::Markup::VERSION
9
- spec.authors = ["Alvaro Faundez"]
10
- spec.email = ["alvaro@faundez.net"]
8
+ spec.authors = ['Alvaro Faundez']
9
+ spec.email = ['alvaro@faundez.net']
11
10
 
12
- spec.summary = %q{Jekyll plugin to use Haml on templates.}
13
- spec.description = %q{Jekyll plugin that add the option to write layouts and partials in Haml.}
11
+ spec.summary = 'Jekyll plugin to use Haml on templates.'
12
+ spec.description = 'Jekyll plugin that add the option to write layouts' \
13
+ ' and partials in Haml.'
14
14
  spec.homepage = 'https://github.com/afaundez/jekyll-haml-markup'
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
18
  f.match(%r{^(test|spec|features)/})
19
19
  end
20
- spec.bindir = "exe"
20
+ spec.bindir = 'exe'
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
22
+ spec.require_paths = ['lib']
23
23
 
24
24
  spec.required_ruby_version = '>= 2.1.0'
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.16"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "minitest", "~> 5.0"
26
+ spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'minitest', '~> 5.0'
29
28
  spec.add_development_dependency 'nokogiri', '~> 1.6', '>= 1.6.8'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'rubocop', '~> 0.57', '>= 0.57.2'
30
31
 
31
- spec.add_runtime_dependency 'jekyll', '~> 3.0'
32
- spec.add_runtime_dependency 'haml', '~> 4'
32
+ spec.add_runtime_dependency 'haml', '~> 5.0', '>= 5.0.0'
33
+ spec.add_runtime_dependency 'jekyll', '>= 3.0', '< 5.0'
33
34
  end
@@ -6,9 +6,10 @@ require_relative 'markup/hooks'
6
6
 
7
7
  module Jekyll
8
8
  module Haml
9
+ # markup module
9
10
  module Markup
10
11
  def self.root
11
- Pathname.new File.expand_path('../../../..', __FILE__)
12
+ Pathname.new File.expand_path('../../..', __dir__)
12
13
  end
13
14
  end
14
15
  end
@@ -2,41 +2,18 @@ require 'jekyll'
2
2
 
3
3
  module Jekyll
4
4
  module Converters
5
+ # haml converter
5
6
  class Haml < Converter
6
-
7
- def extname_list
8
- @extname_list ||= haml_conf["haml_ext"].split(",").map do |e|
9
- ".#{e.downcase}"
10
- end
11
- end
12
-
13
7
  def matches(ext)
14
- extname_list.include?(ext.downcase)
8
+ Jekyll::Haml::Parser.matches ext
15
9
  end
16
10
 
17
- def output_ext(ext)
11
+ def output_ext(_ext)
18
12
  '.html'
19
13
  end
20
14
 
21
- def get_processor
22
- case haml_conf['haml'].downcase
23
- when 'lib-haml' then return Jekyll::Haml::Parser.new haml_conf
24
- end
25
- end
26
-
27
15
  def convert(content)
28
- get_processor.convert content
29
- end
30
-
31
- def haml_conf
32
- {
33
- 'haml_ext' => 'haml',
34
- 'haml' => 'lib-haml',
35
- 'lib-haml' => {
36
- attr_wrapper: '"',
37
- escape_attrs: false
38
- }
39
- }
16
+ Jekyll::Haml::Parser.compile content
40
17
  end
41
18
  end
42
19
  end
@@ -2,10 +2,9 @@ require 'jekyll'
2
2
 
3
3
  Jekyll::Hooks.register :site, :post_read do |site|
4
4
  haml_converter = Jekyll::Converters::Haml.new site.config
5
- site.layouts.each do |name, layout|
5
+ site.layouts.each do |_, layout|
6
6
  if haml_converter.matches layout.ext
7
- parsed_content = haml_converter.convert layout.content
8
- layout.content = parsed_content
7
+ layout.content = Jekyll::Haml::Parser.compile layout.content
9
8
  end
10
9
  end
11
10
  end
@@ -3,18 +3,33 @@ require 'liquid'
3
3
 
4
4
  module Jekyll
5
5
  module Tags
6
+ # include module
6
7
  class HamlInclude < IncludeTag
7
-
8
8
  def read_file(file, context)
9
- content = File.read file, file_read_opts(context)
9
+ return super file, context unless matches_a_haml_template file
10
+ file_content = read_file_with_context file, context
11
+ template = split_frontmatter_and_template file_content
12
+ compile_haml_to_html template
13
+ end
10
14
 
11
- config = context.registers[:site].config
12
- haml_converter = Jekyll::Converters::Haml.new config
13
- content = haml_converter.convert(content) if haml_converter.matches File.extname(file)
15
+ private
16
+
17
+ def matches_a_haml_template(file)
18
+ Jekyll::Haml::Parser.matches File.extname file
19
+ end
14
20
 
15
- content
21
+ def read_file_with_context(file, context)
22
+ File.read file, file_read_opts(context)
16
23
  end
17
24
 
25
+ def split_frontmatter_and_template(file_content)
26
+ return $POSTMATCH if file_content =~ Document::YAML_FRONT_MATTER_REGEXP
27
+ file_content
28
+ end
29
+
30
+ def compile_haml_to_html(template)
31
+ Jekyll::Haml::Parser.compile template
32
+ end
18
33
  end
19
34
  end
20
35
  end
@@ -2,39 +2,18 @@ require 'haml'
2
2
 
3
3
  module Jekyll
4
4
  module Haml
5
+ # parse module
5
6
  class Parser
7
+ CONFIG = { attr_wrapper: '"', escape_attrs: false }.freeze
6
8
 
7
- def initialize(config)
8
- unless defined?(Haml)
9
- Jekyll::External.require_with_graceful_fail "haml"
10
- end
11
- @config = config["lib-haml"] || {}
12
- setup
9
+ def self.matches(ext)
10
+ ext =~ /^\.haml$/i
13
11
  end
14
12
 
15
- def setup
16
- make_accessible
13
+ def self.compile(content)
14
+ template = ::Haml::Engine.new content, CONFIG
15
+ template.render.split("\n").join
17
16
  end
18
-
19
- def convert(content)
20
- document = ::Haml::Engine.new(content, @config)
21
- html_output = document.render.split("\n").join
22
- if @config["show_warnings"]
23
- document.warnings.each do |warning|
24
- Jekyll.logger.warn "Haml warning:", warning
25
- end
26
- end
27
- html_output
28
- end
29
-
30
- private
31
- def make_accessible(hash = @config)
32
- hash.keys.each do |key|
33
- hash[key.to_sym] = hash[key]
34
- make_accessible(hash[key]) if hash[key].is_a?(Hash)
35
- end
36
- end
37
-
38
17
  end
39
18
  end
40
19
  end
@@ -1,7 +1,7 @@
1
1
  module Jekyll
2
2
  module Haml
3
3
  module Markup
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.5'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-haml-markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alvaro Faundez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-26 00:00:00.000000000 Z
11
+ date: 2019-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,81 +25,113 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '5.0'
34
34
  type: :development
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: '10.0'
40
+ version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest
42
+ name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: '1.6'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.6.8
48
51
  type: :development
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
55
  - - "~>"
53
56
  - !ruby/object:Gem::Version
54
- version: '5.0'
57
+ version: '1.6'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.6.8
55
61
  - !ruby/object:Gem::Dependency
56
- name: nokogiri
62
+ name: rake
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '1.6'
67
+ version: '10.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubocop
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.57'
62
82
  - - ">="
63
83
  - !ruby/object:Gem::Version
64
- version: 1.6.8
84
+ version: 0.57.2
65
85
  type: :development
66
86
  prerelease: false
67
87
  version_requirements: !ruby/object:Gem::Requirement
68
88
  requirements:
69
89
  - - "~>"
70
90
  - !ruby/object:Gem::Version
71
- version: '1.6'
91
+ version: '0.57'
72
92
  - - ">="
73
93
  - !ruby/object:Gem::Version
74
- version: 1.6.8
94
+ version: 0.57.2
75
95
  - !ruby/object:Gem::Dependency
76
- name: jekyll
96
+ name: haml
77
97
  requirement: !ruby/object:Gem::Requirement
78
98
  requirements:
79
99
  - - "~>"
80
100
  - !ruby/object:Gem::Version
81
- version: '3.0'
101
+ version: '5.0'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 5.0.0
82
105
  type: :runtime
83
106
  prerelease: false
84
107
  version_requirements: !ruby/object:Gem::Requirement
85
108
  requirements:
86
109
  - - "~>"
87
110
  - !ruby/object:Gem::Version
88
- version: '3.0'
111
+ version: '5.0'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 5.0.0
89
115
  - !ruby/object:Gem::Dependency
90
- name: haml
116
+ name: jekyll
91
117
  requirement: !ruby/object:Gem::Requirement
92
118
  requirements:
93
- - - "~>"
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '3.0'
122
+ - - "<"
94
123
  - !ruby/object:Gem::Version
95
- version: '4'
124
+ version: '5.0'
96
125
  type: :runtime
97
126
  prerelease: false
98
127
  version_requirements: !ruby/object:Gem::Requirement
99
128
  requirements:
100
- - - "~>"
129
+ - - ">="
101
130
  - !ruby/object:Gem::Version
102
- version: '4'
131
+ version: '3.0'
132
+ - - "<"
133
+ - !ruby/object:Gem::Version
134
+ version: '5.0'
103
135
  description: Jekyll plugin that add the option to write layouts and partials in Haml.
104
136
  email:
105
137
  - alvaro@faundez.net