jekyll-pug 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f797b15de38684188dd3e881bbb882b0c5bfffab
4
+ data.tar.gz: 6972df5f89bb45d524afebfe277062051e650481
5
+ SHA512:
6
+ metadata.gz: e261fdbf0ba394a9282cfe1c3a0bd777efb8eeefa6cb67e1fc3340a6a21c64314cd57a04dff3db1c2915868403d554978ee8d50da1f2276b67078b4eb0b35a94
7
+ data.tar.gz: c22559b5080567e8d3a2e0ecd8b5312e481a409d8c9268ea67ff46305a4c5cdf47be34dccbe6777a0c37b16532ed7eaff21dc7253626fcb1c99f9a8fa1add729
Binary file
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-pug.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017 Doug Beney
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.
@@ -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-pug'
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-pug
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
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "jekyll-pug"
7
+ gem.version = "0.0.1"
8
+ gem.authors = ["Doug Beney"]
9
+ gem.email = ["work@dougbeney.com"]
10
+ gem.description = %q{Pug to HTML converter for Jekyll}
11
+ gem.summary = %q{Convert Pug files to standard HTML files as part of your Jekyll build.}
12
+ gem.homepage = "https://github.com/DougBeney/jekyll-pug"
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+
19
+ gem.add_runtime_dependency 'jekyll', '>= 3.3.0'
20
+ gem.add_runtime_dependency 'pug-ruby', '>= 1.0'
21
+ end
Binary file
@@ -0,0 +1,23 @@
1
+ require "pug-ruby"
2
+
3
+ require "jekyll-pug/tags/pug_partial"
4
+ require "jekyll-pug/ext/convertible"
5
+
6
+ module Jekyll
7
+ class PugConverter < Converter
8
+ safe true
9
+ priority :low
10
+
11
+ def matches(ext)
12
+ ext =~ /^\.pug$/i
13
+ end
14
+
15
+ def output_ext(ext)
16
+ ".html"
17
+ end
18
+
19
+ def convert(content)
20
+ return Pug.compile(content, {"filename"=>"./_includes/."})
21
+ end
22
+ end
23
+ end
Binary file
@@ -0,0 +1,19 @@
1
+ # Re-open Layout class to convert our Pug 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,67 @@
1
+ require 'pug-ruby'
2
+ require 'open3'
3
+
4
+ module Jekyll
5
+ class PugPartialTag < Liquid::Tag
6
+ isHTML = false
7
+
8
+ def initialize(tag_name, file, tokens)
9
+ super
10
+ @file = file.strip
11
+ end
12
+
13
+ def render(context)
14
+ includes_dir = File.join(context.registers[:site].source, '_includes')
15
+
16
+ if File.symlink?(includes_dir)
17
+ return "Includes directory '#{includes_dir}' cannot be a symlink"
18
+ end
19
+
20
+ if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
21
+ return "Include file '#{@file}' contains invalid characters or sequences"
22
+ end
23
+
24
+ if @file !~ /\.html$/
25
+ isHTML = false
26
+ else
27
+ isHTML = true
28
+ end
29
+
30
+ if @file !~ /\.pug$/
31
+ if !isHTML
32
+ @file << ".pug"
33
+ end
34
+ end
35
+
36
+ Dir.chdir(includes_dir) do
37
+ choices = Dir['**/*'].reject { |x| File.symlink?(x) }
38
+ if choices.include?(@file)
39
+ source = File.read(@file)
40
+ if !isHTML
41
+ conversion = Pug.compile(source, {"filename" => includes_dir + "/."})
42
+ else
43
+ conversion = source
44
+ end
45
+ partial = Liquid::Template.parse(conversion)
46
+ begin
47
+ return partial.render!(context)
48
+ rescue => e
49
+ puts "Liquid Exception: #{e.message} in #{data['layout']}"
50
+ e.backtrace.each do |backtrace|
51
+ puts backtrace
52
+ end
53
+ abort('Build Failed')
54
+ end
55
+
56
+ context.stack do
57
+ return partial.render(context)
58
+ end
59
+ else
60
+ "Included file '#{@file}' not found in _includes directory"
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ Liquid::Template.register_tag('include', Jekyll::PugPartialTag)
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :jekyll_plugins do
4
+ gem "jekyll-pug", :path => "../"
5
+ end
@@ -0,0 +1 @@
1
+ p Copyright 2017 - All Rights Reserved. - (Just kidding! Open-Source, baby!)
@@ -0,0 +1,5 @@
1
+ nav
2
+ ul
3
+ li Home
4
+ li About
5
+ li: a(href="https://dougbeney.com/contact/") Contact
@@ -0,0 +1,8 @@
1
+ - var cool_variable = "I am a cool variable!!";
2
+
3
+ mixin list_stuff
4
+ h1 This list is generated with a Pug mixin
5
+ ul
6
+ li One
7
+ li Two
8
+ li Three
@@ -0,0 +1,19 @@
1
+ include variables_and_mixins
2
+
3
+ doctype
4
+ html
5
+ head
6
+ title {{page.title}}
7
+ link(rel="stylesheet", href="/main.css")
8
+ body
9
+ .container
10
+ h1 {{page.title}}
11
+ | {% include nav %}
12
+ .content {{content}}
13
+
14
+ +list_stuff
15
+
16
+ h1 Check out this Pug variable:
17
+ p= cool_variable
18
+
19
+ | {% include footer %}
@@ -0,0 +1 @@
1
+ <!DOCTYPE html><html><head><title>Welcome To The Jekyll-Pug Example Site!</title><link rel="stylesheet" href="/main.css"></head><body><div class="container"><h1>Welcome To The Jekyll-Pug Example Site!</h1><nav><ul><li>Home</li><li>About</li><li><a href="https://dougbeney.com/contact/">Contact</a></li></ul></nav><div class="content"><p><strong>If you're interested in contributing to Jekyll-Pug, use this sample site to help you debug.</strong></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p></div><h1>This list is generated with a Pug mixin</h1><ul><li>One</li><li>Two</li><li>Three</li></ul><h1>Check out this Pug variable:</h1><p>I am a cool variable!!</p><p>Copyright 2017 - All Rights Reserved. - (Just kidding! Open-Source, baby!)</p></div></body></html>
@@ -0,0 +1,27 @@
1
+ html, body{
2
+ font-family: sans-serif;
3
+ line-height: 1.9;
4
+ margin: 0;
5
+ }
6
+
7
+ .container{
8
+ max-width: 750px;
9
+ margin: 0 auto;
10
+ }
11
+
12
+ p, h1, h2, ul{
13
+ margin-top: 30px;
14
+ }
15
+
16
+ nav ul {
17
+ padding: 0;
18
+ display: block;
19
+ width: auto;
20
+ margin: 0 auto;
21
+ background: #ccc;
22
+ text-align: center;
23
+ }
24
+ nav li{
25
+ display: inline;
26
+ margin: 10px 20px;
27
+ }
@@ -0,0 +1 @@
1
+ This is a test Jekyll site - How I debug this plugin.
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: Welcome To The Jekyll-Pug Example Site!
3
+ layout: default
4
+ ---
5
+
6
+ p: strong If you're interested in contributing to Jekyll-Pug, use this sample site to help you debug.
7
+
8
+ p Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@@ -0,0 +1,27 @@
1
+ html, body{
2
+ font-family: sans-serif;
3
+ line-height: 1.9;
4
+ margin: 0;
5
+ }
6
+
7
+ .container{
8
+ max-width: 750px;
9
+ margin: 0 auto;
10
+ }
11
+
12
+ p, h1, h2, ul{
13
+ margin-top: 30px;
14
+ }
15
+
16
+ nav ul {
17
+ padding: 0;
18
+ display: block;
19
+ width: auto;
20
+ margin: 0 auto;
21
+ background: #ccc;
22
+ text-align: center;
23
+ }
24
+ nav li{
25
+ display: inline;
26
+ margin: 10px 20px;
27
+ }
@@ -0,0 +1 @@
1
+ This is a test Jekyll site - How I debug this plugin.
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-pug
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Doug Beney
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-24 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.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: pug-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description: Pug to HTML converter for Jekyll
42
+ email:
43
+ - work@dougbeney.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".DS_Store"
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - jekyll-pug.gemspec
55
+ - lib/.DS_Store
56
+ - lib/jekyll-pug.rb
57
+ - lib/jekyll-pug/.DS_Store
58
+ - lib/jekyll-pug/ext/convertible.rb
59
+ - lib/jekyll-pug/tags/pug_partial.rb
60
+ - test-site/Gemfile
61
+ - test-site/_includes/footer.pug
62
+ - test-site/_includes/nav.pug
63
+ - test-site/_includes/variables_and_mixins.pug
64
+ - test-site/_layouts/default.pug
65
+ - test-site/_site/index.html
66
+ - test-site/_site/main.css
67
+ - test-site/_site/readme.md
68
+ - test-site/index.pug
69
+ - test-site/main.css
70
+ - test-site/readme.md
71
+ homepage: https://github.com/DougBeney/jekyll-pug
72
+ licenses: []
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.6.12
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Convert Pug files to standard HTML files as part of your Jekyll build.
94
+ test_files: []