jekyll-slim 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95e61d06b10c362d79ec9608ebafbc3aa3021643
4
- data.tar.gz: 7016aa481b50a1970eb220134927d838e6dfb00f
3
+ metadata.gz: 863f6d69a418a8703b17f0e0c6f467d77a23742b
4
+ data.tar.gz: f53d213471c0db4fb81483e4df87fe1f600a678b
5
5
  SHA512:
6
- metadata.gz: 070cfe05b5497d9507ded44cdfe199e62145953f59c9e16eeb5bfe7cb9f1eae01a334ce808690eda1e7886743e32317a30d45f74ef6687540977450878ddf7a0
7
- data.tar.gz: 362f4652cb8fb40ff9c454d05363d0d5e41557a50f0872e67a6f490db53f96a31c3680a3ed60db9747db390f3597fe4a69cfb9f256b8d14e6e7760ba019bc4d3
6
+ metadata.gz: dc5ac134af12be7e853de51338113344da7a51e3f619e32b19f96748f58bc66d6faed03c948fe0a06f23b0da370904d0ced7a244432a8d0dccba56f7470253ae
7
+ data.tar.gz: 86abe3bea276baa9698c6170ad6e12255f12e8408f1dd52f5690dd4a54b1242ca7fd5aaabd219a42bfa714e74440d4c14105f51c0855e09beeb84438a5bc69ba
data/History.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.10.0 / 2014-10-10
2
+ ===================
3
+
4
+ * Major refactoring. jekyll-slim uses sliq from now on.
1
5
 
2
6
  0.8.2 / 2013-05-06
3
7
  ==================
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Reda Lemeden
1
+ Copyright (c) 2013 Reda Lemeden, 2014 Daniel Mendler
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
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.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  [![Gem Version](http://img.shields.io/gem/v/jekyll-slim.svg?style=flat)](#)
4
4
  [![Dependency
5
- Status](http://img.shields.io/gemnasium/kaishin/jekyll-slim.svg?style=flat)](https://gemnasium.com/kaishin/jekyll-slim)
5
+ Status](http://img.shields.io/gemnasium/slim-template/jekyll-slim.svg?style=flat)](https://gemnasium.com/slim-template/jekyll-slim)
6
6
  [![Code
7
- Climate](http://img.shields.io/codeclimate/github/kaishin/jekyll-slim.svg?style=flat)](https://codeclimate.com/github/kaishin/jekyll-slim)
8
- [![Build Status](http://img.shields.io/travis/kaishin/jekyll-slim.svg?style=flat)](https://travis-ci.org/kaishin/jekyll-slim)
7
+ Climate](http://img.shields.io/codeclimate/github/slim-template/jekyll-slim.svg?style=flat)](https://codeclimate.com/github/slim-template/jekyll-slim)
8
+ [![Build Status](http://img.shields.io/travis/slim-template/jekyll-slim.svg?style=flat)](https://travis-ci.org/slim-template/jekyll-slim)
9
9
 
10
10
  A gem that adds [slim-lang](http://slim-lang.com) support to [Jekyll](http://github.com/mojombo/jekyll). Works for for pages, includes and layouts.
11
11
 
@@ -25,10 +25,8 @@ Or install it yourself as:
25
25
 
26
26
  In your Jekyll project's `_plugins` directory:
27
27
 
28
- # _plugins/bundler.rb
29
- require 'rubygems'
30
- require 'bundler/setup'
31
- Bundler.require(:default)
28
+ # _plugins/jekyll-slim.rb
29
+ require 'jekyll-slim'
32
30
 
33
31
  ## Usage
34
32
 
@@ -39,8 +37,7 @@ The gem will convert all the `.slim` files in your project's directory into HTML
39
37
  html
40
38
  head
41
39
  body
42
- .content-wrapper
43
- | {{ content }}
40
+ .content-wrapper {{ content }}
44
41
  ```
45
42
  To include a partial, use the `slim` liquid tag instead of `include`:
46
43
 
@@ -51,7 +48,7 @@ layout: default
51
48
  ---
52
49
 
53
50
  section.content Content goes here.
54
- | {% slim footer.slim %}
51
+ % include footer.slim
55
52
 
56
53
  ```
57
54
 
@@ -84,16 +81,9 @@ The `SlimContext` object will be kept across calls, allowing you to easily set
84
81
  `@instance_variables` that can be accessed by **all slim files** even those included with the `slim`
85
82
  liquid tag. Those are more or less global variables in slim templates, so be careful when you use them.
86
83
 
87
- ## TODO
84
+ ## Looking for maintainers
88
85
 
89
- - Per-page slim context?
90
- - Improve code and try to avoid patches as much as possible
91
- - Parsing Liquid tags before slim so you have access to everything? Can create a lot of problems with Ruby
92
- - Slim context must be the same as liquid, with paginator, site, page and content variables. See these links:
93
- - https://github.com/mojombo/jekyll/blob/a9e2a74ea619a01a9d169da2240ce91b43362c9f/lib/jekyll/tags/include.rb
94
- - https://github.com/mojombo/jekyll/blob/a9e2a74ea619a01a9d169da2240ce91b43362c9f/lib/jekyll/page.rb
95
- - http://jekyllrb.com/docs/plugins/
96
- - http://jekyllrb.com/docs/variables/
86
+ We are looking for maintainers for this gem.
97
87
 
98
88
  ## Credit
99
89
 
@@ -1,25 +1,24 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'jekyll-slim/version'
4
+ require 'jekyll/slim/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = 'jekyll-slim'
8
8
  gem.version = Jekyll::Slim::VERSION
9
- gem.authors = ['Reda Lemeden', 'Francesco Belladonna']
10
- gem.email = ['reda@thoughtbot.com', 'francesco.belladonna@gmail.com']
9
+ gem.authors = ['Reda Lemeden', 'Francesco Belladonna', 'Daniel Menlder']
10
+ gem.email = ['reda@thoughtbot.com', 'francesco.belladonna@gmail.com', 'mail@daniel-mendler.de']
11
11
  gem.description = %q{Slim html converter for Jekyll}
12
12
  gem.summary = %q{Slim-lang support for Jekyll. Handles includes and layouts as well.}
13
- gem.homepage = ''
13
+ gem.homepage = 'https://github.com/slim-template/jekyll-slim'
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
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', '~> 2.0.0'
21
- gem.add_runtime_dependency 'activesupport', '~> 4.0'
22
- gem.add_runtime_dependency 'slim', '~> 2.0.2'
20
+ gem.add_runtime_dependency 'jekyll', '~> 2.0'
21
+ gem.add_runtime_dependency 'sliq'
23
22
 
24
23
  gem.add_development_dependency('rake')
25
24
  gem.add_development_dependency('bundler')
@@ -1,8 +1 @@
1
- require 'slim'
2
- require 'jekyll-slim/version'
3
- require 'jekyll-slim/extensions/layout'
4
- require 'jekyll-slim/extensions/site'
5
- require 'jekyll-slim/extensions/converter'
6
- require 'jekyll-slim/slim_converter'
7
- require 'jekyll-slim/slim_context'
8
- require 'jekyll-slim/tags/slim_partial'
1
+ require 'jekyll/slim'
@@ -0,0 +1,7 @@
1
+ require 'ostruct'
2
+ require 'sliq'
3
+ require 'jekyll'
4
+ require 'jekyll/slim/version'
5
+ require 'jekyll/slim/extensions'
6
+ require 'jekyll/slim/converter'
7
+ require 'jekyll/slim/include_tag'
@@ -0,0 +1,50 @@
1
+ module Jekyll
2
+ module Slim
3
+ class Converter < ::Jekyll::Converter
4
+ safe false
5
+ priority :low
6
+
7
+ def matches(ext)
8
+ ext =~ /slim/i
9
+ end
10
+
11
+ def output_ext(ext)
12
+ '.html'
13
+ end
14
+
15
+ def convert(content)
16
+ self.class.convert(@config, content)
17
+ end
18
+
19
+ class << self
20
+ def convert(config, content)
21
+ config = symbolize_hash(config['slim'] || {}).merge(file: Convertible.slim_current_convertible.path)
22
+ context = hash2ostruct(Utils.deep_merge_hashes(Convertible.slim_current_convertible.site.site_payload,
23
+ page: Convertible.slim_current_convertible.to_liquid))
24
+ # Allow also direct access to the site and page object from Slim
25
+ context.site_object = Convertible.slim_current_convertible.site
26
+ context.page_object = Convertible.slim_current_convertible
27
+ ::Sliq::Converter.new(config) { content }.render(context)
28
+ end
29
+
30
+ def hash2ostruct(hash)
31
+ h = {}
32
+ hash.keys.each do |k|
33
+ v = hash[k]
34
+ h[k] = Hash === v ? hash2ostruct(v) : v
35
+ end
36
+ OpenStruct.new(h)
37
+ end
38
+
39
+ def symbolize_hash(hash)
40
+ h = {}
41
+ hash.keys.each do |k|
42
+ v = hash[k]
43
+ h[(k.to_sym rescue k) || k] = Hash === v ? symbolize_hash(v) : v
44
+ end
45
+ h
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,34 @@
1
+ module Jekyll
2
+ class Layout
3
+ # path is required
4
+ # Also related to https://github.com/mojombo/jekyll/issues/225
5
+ def path
6
+ @name
7
+ end
8
+
9
+ # Allows layouts to be transformed by slim until this is fixed (1.4)
10
+ # https://github.com/mojombo/jekyll/issues/225
11
+ # https://github.com/mojombo/jekyll/blob/master/lib/jekyll/layout.rb
12
+ alias old_initialize initialize
13
+ def initialize(*args)
14
+ old_initialize(*args)
15
+ transform
16
+ end
17
+
18
+ def to_liquid
19
+ data.merge(name: name, content: content)
20
+ end
21
+ end
22
+
23
+ module Convertible
24
+ class<< self
25
+ attr_accessor :slim_current_convertible
26
+ end
27
+
28
+ alias old_transform transform
29
+ def transform
30
+ Convertible.slim_current_convertible = self
31
+ old_transform
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,17 @@
1
+ module Jekyll
2
+ module Slim
3
+ class IncludeTag < Jekyll::Tags::IncludeTag
4
+ def source(file, context)
5
+ content = super
6
+ if file =~ /\.slim\Z/i
7
+ Converter.convert(context.registers[:site].config, content)
8
+ else
9
+ content
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ Liquid::Template.register_tag('slim', Jekyll::Slim::IncludeTag)
17
+ Liquid::Template.register_tag('include', Jekyll::Slim::IncludeTag)
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Slim
3
- VERSION = "0.9.1"
3
+ VERSION = '0.10.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-slim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reda Lemeden
8
8
  - Francesco Belladonna
9
+ - Daniel Menlder
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-06-07 00:00:00.000000000 Z
13
+ date: 2014-10-15 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: jekyll
@@ -17,42 +18,28 @@ dependencies:
17
18
  requirements:
18
19
  - - "~>"
19
20
  - !ruby/object:Gem::Version
20
- version: 2.0.0
21
+ version: '2.0'
21
22
  type: :runtime
22
23
  prerelease: false
23
24
  version_requirements: !ruby/object:Gem::Requirement
24
25
  requirements:
25
26
  - - "~>"
26
27
  - !ruby/object:Gem::Version
27
- version: 2.0.0
28
+ version: '2.0'
28
29
  - !ruby/object:Gem::Dependency
29
- name: activesupport
30
+ name: sliq
30
31
  requirement: !ruby/object:Gem::Requirement
31
32
  requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '4.0'
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '4.0'
42
- - !ruby/object:Gem::Dependency
43
- name: slim
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
33
+ - - ">="
47
34
  - !ruby/object:Gem::Version
48
- version: 2.0.2
35
+ version: '0'
49
36
  type: :runtime
50
37
  prerelease: false
51
38
  version_requirements: !ruby/object:Gem::Requirement
52
39
  requirements:
53
- - - "~>"
40
+ - - ">="
54
41
  - !ruby/object:Gem::Version
55
- version: 2.0.2
42
+ version: '0'
56
43
  - !ruby/object:Gem::Dependency
57
44
  name: rake
58
45
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +86,7 @@ description: Slim html converter for Jekyll
99
86
  email:
100
87
  - reda@thoughtbot.com
101
88
  - francesco.belladonna@gmail.com
89
+ - mail@daniel-mendler.de
102
90
  executables: []
103
91
  extensions: []
104
92
  extra_rdoc_files: []
@@ -110,18 +98,14 @@ files:
110
98
  - History.md
111
99
  - LICENSE.txt
112
100
  - README.md
113
- - Rakefile
114
101
  - jekyll-slim.gemspec
115
102
  - lib/jekyll-slim.rb
116
- - lib/jekyll-slim/extensions/converter.rb
117
- - lib/jekyll-slim/extensions/layout.rb
118
- - lib/jekyll-slim/extensions/site.rb
119
- - lib/jekyll-slim/slim_context.rb
120
- - lib/jekyll-slim/slim_converter.rb
121
- - lib/jekyll-slim/tags/slim_partial.rb
122
- - lib/jekyll-slim/version.rb
123
- - spec/spec_helper.rb
124
- homepage: ''
103
+ - lib/jekyll/slim.rb
104
+ - lib/jekyll/slim/converter.rb
105
+ - lib/jekyll/slim/extensions.rb
106
+ - lib/jekyll/slim/include_tag.rb
107
+ - lib/jekyll/slim/version.rb
108
+ homepage: https://github.com/slim-template/jekyll-slim
125
109
  licenses: []
126
110
  metadata: {}
127
111
  post_install_message:
@@ -144,5 +128,5 @@ rubygems_version: 2.2.2
144
128
  signing_key:
145
129
  specification_version: 4
146
130
  summary: Slim-lang support for Jekyll. Handles includes and layouts as well.
147
- test_files:
148
- - spec/spec_helper.rb
131
+ test_files: []
132
+ has_rdoc:
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,10 +0,0 @@
1
- module Jekyll
2
- class Converter < Plugin
3
-
4
- # Patch used to export site variable to converters
5
- def locals(locals=nil)
6
- @locals = locals if locals
7
- @locals
8
- end
9
- end
10
- end
@@ -1,19 +0,0 @@
1
- module Jekyll
2
- class Layout
3
-
4
- # Allows layouts to be transformed by slim until this is fixed (1.4)
5
- # https://github.com/mojombo/jekyll/issues/225
6
- # https://github.com/mojombo/jekyll/blob/master/lib/jekyll/layout.rb
7
- def initialize(site, base, name)
8
- @site = site
9
- @base = base
10
- @name = name
11
-
12
- self.data = {}
13
-
14
- self.process(name)
15
- self.read_yaml(base, name)
16
- self.transform
17
- end
18
- end
19
- end
@@ -1,26 +0,0 @@
1
- require 'jekyll-slim/slim_context'
2
-
3
- module Jekyll
4
- class Site
5
-
6
- attr_reader :slim_context
7
-
8
- # Patch to allow usage of site variable in Slim/Haml
9
- # https://blog.darmasoft.net/2012/02/29/haml-processing-in-jekyll.html
10
- # https://github.com/mojombo/jekyll/blob/master/lib/jekyll/site.rb
11
- def instantiate_subclasses(klass)
12
- klass.subclasses.select do |c|
13
- !self.safe || c.safe
14
- end.sort.map do |c|
15
- conv = c.new(self.config)
16
- # XXX: Hotfix to allow access site variable in slim/haml templates
17
- if conv.respond_to?(:locals)
18
- @slim_context ||= SlimContext.new(self)
19
- conv.locals({ slim_context: @slim_context })
20
- end
21
-
22
- conv
23
- end
24
- end
25
- end
26
- end
@@ -1,12 +0,0 @@
1
- class SlimContext
2
- attr_accessor :params
3
-
4
- def initialize(site_context)
5
- # XXX: Hopefully user won't overwrite this instance variable
6
- @__site = site_context
7
- end
8
-
9
- def site
10
- @__site
11
- end
12
- end
@@ -1,34 +0,0 @@
1
- require 'slim'
2
-
3
- module Jekyll
4
- class SlimConverter < Converter
5
- safe false
6
- priority :low
7
-
8
- def initialize(config)
9
- super
10
- self.ensure_config_integrity
11
- end
12
-
13
- def matches(ext)
14
- ext =~ /slim/i
15
- end
16
-
17
- def output_ext(ext)
18
- ".html"
19
- end
20
-
21
- def convert(content)
22
- begin
23
- ::Slim::Template.new(@symbolized_config) { content }.render(locals[:slim_context])
24
- rescue StandardError => e
25
- puts "(!) SLIM ERROR: " + e.message
26
- end
27
- end
28
-
29
- def ensure_config_integrity
30
- @config['slim'] ||= {}
31
- @symbolized_config = @config['slim'].deep_symbolize_keys
32
- end
33
- end
34
- end
@@ -1,94 +0,0 @@
1
- require 'slim'
2
-
3
- module Jekyll
4
- class SlimPartialTag < Liquid::Tag
5
-
6
- SYNTAX_EXAMPLE = "{% slim file.slim param='value' param2='value' %}"
7
-
8
- VALID_SYNTAX = /([\w-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))/
9
-
10
- def initialize(tag_name, markup, tokens)
11
- super
12
- @file, @params = markup.strip.split(' ', 2)
13
- validate_params if @params
14
- end
15
-
16
- def validate_params
17
- full_valid_syntax = Regexp.compile('\A\s*(?:' + VALID_SYNTAX.to_s + '(?=\s|\z)\s*)*\z')
18
- unless @params =~ full_valid_syntax
19
- raise ArgumentError.new <<-eos
20
- Invalid syntax for include tag:
21
- #{@params}
22
-
23
- Valid syntax:
24
- #{SYNTAX_EXAMPLE}
25
- eos
26
- end
27
- end
28
-
29
- def parse_params(context)
30
- params = {}
31
- markup = @params
32
-
33
- while match = VALID_SYNTAX.match(markup) do
34
- markup = markup[match.end(0)..-1]
35
-
36
- value = if match[2]
37
- match[2].gsub(/\\"/, '"')
38
- elsif match[3]
39
- match[3].gsub(/\\'/, "'")
40
- elsif match[4]
41
- slim_context[match[4]]
42
- end
43
-
44
- params[match[1]] = value
45
- end
46
- params
47
- end
48
-
49
- def render(context)
50
- includes_dir = File.join(context.registers[:site].source, '_includes')
51
-
52
- if File.symlink?(includes_dir)
53
- return "Includes directory '#{includes_dir}' cannot be a symlink"
54
- end
55
-
56
- if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
57
- return "Include file '#{@file}' contains invalid characters or sequences"
58
- end
59
-
60
- return "File must have \".slim\" extension" if @file !~ /\.slim$/
61
-
62
- Dir.chdir(includes_dir) do
63
- choices = Dir['**/*'].reject { |x| File.symlink?(x) }
64
- if choices.include?(@file)
65
- source = File.read(@file)
66
- context.registers[:site].slim_context.params = parse_params(context.registers[:site].slim_context)
67
- conversion = ::Slim::Template.new(context.registers[:site].config['slim'].deep_symbolize_keys) { source }.render(context.registers[:site].slim_context)
68
- partial = Liquid::Template.parse(conversion)
69
- begin
70
- return partial.render!(context)
71
- rescue => e
72
- if self.respond_to?(:data)
73
- puts "Liquid Exception: #{e.message} in #{self.data["layout"]}"
74
- else
75
- puts "Liquid Exception: #{e.message} in (Unknown layout)"
76
- end
77
- e.backtrace.each do |backtrace|
78
- puts backtrace
79
- end
80
- abort("Build Failed")
81
- end
82
-
83
- context.stack do
84
- return partial.render(context)
85
- end
86
- else
87
- "Included file '#{@file}' not found in _includes directory"
88
- end
89
- end
90
- end
91
- end
92
- end
93
-
94
- Liquid::Template.register_tag('slim', Jekyll::SlimPartialTag)
@@ -1,17 +0,0 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # Require this file using `require "spec_helper"` to ensure that it is only
4
- # loaded once.
5
- #
6
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
- RSpec.configure do |config|
8
- config.treat_symbols_as_metadata_keys_with_true_values = true
9
- config.run_all_when_everything_filtered = true
10
- config.filter_run :focus
11
-
12
- # Run specs in random order to surface order dependencies. If you find an
13
- # order dependency and want to debug it, you can fix the order by providing
14
- # the seed, which is printed after each run.
15
- # --seed 1234
16
- config.order = 'random'
17
- end