jekyll-haml-improved 0.1
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 +7 -0
- data/.gitignore +17 -0
- data/CHANGELOG.md +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +77 -0
- data/Rakefile +1 -0
- data/jekyll-haml-improved.gemspec +23 -0
- data/lib/jekyll-haml-improved.rb +24 -0
- data/lib/jekyll-haml-improved/ext/convertible.rb +19 -0
- data/lib/jekyll-haml-improved/tags/haml_partial.rb +53 -0
- data/lib/jekyll-haml-improved/version.rb +5 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 33dae2f593ed8f4176b7025bebfec40ea5f53b433d232b91dd0b29e3d99aaf74
|
4
|
+
data.tar.gz: 8387c1cf85726fe39f1e777c3c68fbdec73e6f523e6b1462f156923696a0961c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80b26dd0db6918b0ae16ed0f73369d2d8d9d6172c652fd23bae4cc33ca5d993d0321e54113b6ff5d8e55e1b896432e35e01a3bc0c015841e8bc42de9e1f2bfe7
|
7
|
+
data.tar.gz: 4cf40d39ad369f4a0f9eb32d9975a60ac6887b006eaada14ce2738b30639ce747e31b735b0821d46b0e9437933877b974222627902fd1d4c2946b6180e4ed36d
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
## 0.1.6 2017-11-10
|
2
|
+
### minor enhancements
|
3
|
+
* removes newlines from `{% haml %}` includes - ([@pedrozath][])
|
4
|
+
|
5
|
+
## 0.1.5 2016-12-30
|
6
|
+
### minor enhancements
|
7
|
+
* Fixed an error with Jekyll 3.3.0 and later https://github.com/samvincent/jekyll-haml-improved/issues/19
|
8
|
+
|
9
|
+
## 0.1.4 2016-06-01
|
10
|
+
### minor enhancements
|
11
|
+
* Fixed loss of content in layout conversion - ([@sspreitzer][])
|
12
|
+
|
13
|
+
## 0.1.3 2015-12-08
|
14
|
+
### minor enhancements
|
15
|
+
* Fixed an error with Jekyll 2.3.0 (and probably with prior versions) that crashes when building the site - ([@kalvinarts][])
|
16
|
+
|
17
|
+
## 0.1.2 2015-04-28
|
18
|
+
### minor enhancements
|
19
|
+
* Follow Jekyll 2.3.0 internal API change - ([@yaegashi][])
|
20
|
+
|
21
|
+
## 0.1.1 2012-12-04
|
22
|
+
### minor enhancements
|
23
|
+
* Fix issue where layout was not parsing yaml front matter. - ([@simonreed][])
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Sam Vincent
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Jekyll::Haml
|
2
|
+
|
3
|
+
This gem provides a [Jekyll](http://github.com/mojombo/jekyll) converter for
|
4
|
+
[Haml](http://haml.info) files.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
If using [Bundler](http://gembundler.com), add these lines to your application's Gemfile:
|
9
|
+
|
10
|
+
```rb
|
11
|
+
group :jekyll_plugins do
|
12
|
+
gem 'jekyll-haml-improved'
|
13
|
+
end
|
14
|
+
```
|
15
|
+
|
16
|
+
Alternatively, if you don't use Bundler, just update your Jekyll project's `_config.yml`:
|
17
|
+
|
18
|
+
```yml
|
19
|
+
gems:
|
20
|
+
- jekyll-haml-improved
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
You'll be able to use all of Haml's tricks to write some really clean markup. You can use liquid filters easily by just rendering the liquid tags as shown below. Have fun!
|
26
|
+
|
27
|
+
```haml
|
28
|
+
---
|
29
|
+
title: Story Time
|
30
|
+
permalink: page/
|
31
|
+
---
|
32
|
+
.container
|
33
|
+
%h3= "{% title %}"
|
34
|
+
|
35
|
+
:javascript
|
36
|
+
$(document).ready(function(){});
|
37
|
+
```
|
38
|
+
|
39
|
+
### Markdown blocks
|
40
|
+
|
41
|
+
For clean content blocks, I find it helps to use Haml's `:markdown` filter if I can get away with it.
|
42
|
+
|
43
|
+
```haml
|
44
|
+
.content
|
45
|
+
:markdown
|
46
|
+
*Dec 4, 2012* - [Author](http://github.com)
|
47
|
+
|
48
|
+
Once upon a time, in a village by the sea...
|
49
|
+
```
|
50
|
+
|
51
|
+
### Partials
|
52
|
+
|
53
|
+
The gem adds the liquid filter `haml` so you can render `_includes` that are written in Haml as well.
|
54
|
+
|
55
|
+
```liquid
|
56
|
+
{% haml comments.haml %}
|
57
|
+
```
|
58
|
+
|
59
|
+
```haml
|
60
|
+
-# _includes/meta.haml
|
61
|
+
%meta{property: 'og:type', content: 'website'}
|
62
|
+
%meta{name: 'viewport', content: 'width=device-width'}
|
63
|
+
```
|
64
|
+
|
65
|
+
## About
|
66
|
+
|
67
|
+
I originally searched around the internet for a quick way to integrate HAML into my jekyll workflow and found a few around the internet to convert haml in different cases (layouts, partials, and posts). This gem is really just a collection of those techniques so they're easy to find and you can get back to creating your site using the slickest markup. It's made to drop in to your `Gemfile` just as easily as [jekyll-sass](https://github.com/noct/jekyll-sass).
|
68
|
+
|
69
|
+
If you're using this stuff, you may also be interested in [Octopress](http://octopress.org). I believe it includes support for Haml/Sass out of the gate.
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
1. Fork it
|
74
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
75
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
76
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
77
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jekyll-haml-improved/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "jekyll-haml-improved"
|
8
|
+
gem.version = 0.1
|
9
|
+
gem.authors = ["Fumi Ogawa"]
|
10
|
+
gem.email = ["fuminori@educity.asia"]
|
11
|
+
gem.description = %q{The improved(fixed) version of jekyll-haml}
|
12
|
+
gem.summary = %q{Convert HAML files to standard HTML files as part of your Jekyll build.}
|
13
|
+
gem.homepage = "https://github.com/mizphses/jekyll-haml-improved"
|
14
|
+
gem.license = "MIT"
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_runtime_dependency 'jekyll', '~> 3.3', '>= 3.3.0'
|
22
|
+
gem.add_runtime_dependency 'haml', '~> 3.0', '>= 3.0.0'
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "jekyll-haml-improved/version"
|
2
|
+
require "haml"
|
3
|
+
|
4
|
+
require "jekyll-haml-improved/tags/haml_partial"
|
5
|
+
require "jekyll-haml-improved/ext/convertible"
|
6
|
+
|
7
|
+
module Jekyll
|
8
|
+
class HamlConverter < Converter
|
9
|
+
safe true
|
10
|
+
priority :low
|
11
|
+
|
12
|
+
def matches(ext)
|
13
|
+
ext =~ /haml/i
|
14
|
+
end
|
15
|
+
|
16
|
+
def output_ext(ext)
|
17
|
+
".html"
|
18
|
+
end
|
19
|
+
|
20
|
+
def convert(content)
|
21
|
+
::Haml::Engine.new(content).render
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Re-open Layout class to convert our HAML Layout content.
|
2
|
+
module Jekyll
|
3
|
+
class Layout
|
4
|
+
alias old_initialize initialize
|
5
|
+
|
6
|
+
def initialize(*args)
|
7
|
+
old_initialize(*args)
|
8
|
+
self.content = transform
|
9
|
+
end
|
10
|
+
|
11
|
+
def transform
|
12
|
+
_renderer.convert(content)
|
13
|
+
end
|
14
|
+
|
15
|
+
def extname
|
16
|
+
ext
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'haml'
|
2
|
+
|
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"
|
16
|
+
end
|
17
|
+
|
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.delete("\n")
|
29
|
+
partial = Liquid::Template.parse(conversion)
|
30
|
+
begin
|
31
|
+
return partial.render!(context)
|
32
|
+
rescue => e
|
33
|
+
print "Liquid Exception: #{e.message}"
|
34
|
+
print "in #{self.data["layout"]}"
|
35
|
+
e.backtrace.each do |backtrace|
|
36
|
+
puts backtrace
|
37
|
+
end
|
38
|
+
abort("Build Failed")
|
39
|
+
end
|
40
|
+
|
41
|
+
context.stack do
|
42
|
+
return partial.render(context)
|
43
|
+
end
|
44
|
+
else
|
45
|
+
"Included file '#{@file}' not found in _includes directory"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
Liquid::Template.register_tag('haml', Jekyll::HamlPartialTag)
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-haml-improved
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fumi Ogawa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.3.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.3'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.3.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: haml
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 3.0.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 3.0.0
|
53
|
+
description: The improved(fixed) version of jekyll-haml
|
54
|
+
email:
|
55
|
+
- fuminori@educity.asia
|
56
|
+
executables: []
|
57
|
+
extensions: []
|
58
|
+
extra_rdoc_files: []
|
59
|
+
files:
|
60
|
+
- ".gitignore"
|
61
|
+
- CHANGELOG.md
|
62
|
+
- Gemfile
|
63
|
+
- LICENSE.txt
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- jekyll-haml-improved.gemspec
|
67
|
+
- lib/jekyll-haml-improved.rb
|
68
|
+
- lib/jekyll-haml-improved/ext/convertible.rb
|
69
|
+
- lib/jekyll-haml-improved/tags/haml_partial.rb
|
70
|
+
- lib/jekyll-haml-improved/version.rb
|
71
|
+
homepage: https://github.com/mizphses/jekyll-haml-improved
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubygems_version: 3.1.4
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Convert HAML files to standard HTML files as part of your Jekyll build.
|
94
|
+
test_files: []
|