jekyll-template 0.2.0 → 0.3.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: 2829d7ec307e92b374fe19c457799f14b4452584
4
- data.tar.gz: 6977dfb523c12d594d59c904f8c73aafdf189107
3
+ metadata.gz: cbaf9542ef68675be688856585381ee273716af0
4
+ data.tar.gz: 3cb196191b5eef544a7e2d714736ba4d8455f6b2
5
5
  SHA512:
6
- metadata.gz: a43a38f471ec4b989d954703eae5c538e38862e4060605084608890f1e51d3c6935e27b217d0aa188a38f517a03f2545a489cf079b9e271e946899c6433a6aae
7
- data.tar.gz: fd130fa5c6b3e938702f7756ae88e3aac9d6c18818ecf517d7eacd5c5bca1d3addc04c803e99d790df6fad737abf995d95440ca4d040e1f90cad97cb0c501d7a
6
+ metadata.gz: 6361f538145c5f0d03fd4778b861042355e95b63a737943e44ccba4a43dc1c0e83a0de7695a85afa05316b669526fb8dc9eddb5dec728a99e76359db816e76e5
7
+ data.tar.gz: 0c82dc7b6d99d39aa22ba787a8f90c5364bda759917cdbd6e9c50c59e36c08a0751c2ae1f10582f44df2747dafc9036363ac72077c1e93df6aaf08f600861197
data/.travis.yml CHANGED
@@ -3,3 +3,9 @@ language: ruby
3
3
  rvm:
4
4
  - 2.3.3
5
5
  before_install: gem install bundler -v 1.13.7
6
+
7
+ install:
8
+ - bundle install
9
+
10
+ script:
11
+ - bundle exec rake test
data/Gemfile CHANGED
@@ -1,6 +1,2 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
-
4
- gem "jekyll", "3.1.2"
5
- gem "htmlcompressor", "~> 0.3.1"
6
- gem "unindent", "~> 1.0"
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # Jekyll::Template
1
+ # jekyll-template [![Build Status](https://travis-ci.org/helpscout/jekyll-template.svg?branch=master)](https://travis-ci.org/helpscout/jekyll-template)
2
+
3
+ Custom template block with YAML front matter support for Jekyll
4
+
2
5
 
3
6
  ## Installation
4
7
 
@@ -17,3 +20,148 @@ Or install it yourself as:
17
20
  ```
18
21
  gem install jekyll-template
19
22
  ```
23
+
24
+
25
+
26
+ ---
27
+
28
+
29
+
30
+ ## Documentation
31
+
32
+ Templates (`{% template %}`) work similarly to Jekyll's `{% include %}` tag. It references an existing `.html` file for markup. However, the biggest difference (and most awesome feature) between `{% template %}` vs. `{% include %}` is that templates allow for content to be used inside the block.
33
+
34
+ ### Setting up the template directory
35
+
36
+ The first thing you have to do to allow for template blocks to work is to create a new directory called `_templates` within your Jekyll site's source directory:
37
+
38
+ ```
39
+ my-jekyll-site/
40
+ ├── _data/
41
+ ├── _includes/
42
+ ├── _plugins/
43
+ ├── _posts/
44
+ ├── _templates/ <-- Right here!
45
+ └── index.md
46
+ ```
47
+
48
+ Once you have your directory created, add template files as regular `.html` files (just like you would `_includes/` files).
49
+
50
+
51
+ ### Creating a template file
52
+
53
+ Let's create a template file called `awesome.html`, which will be added to `_templates`.
54
+ (Full path is `_templates/awesome.html`)
55
+
56
+ ```markdown
57
+ <div class="awesome">
58
+ {{ template.content }}
59
+ </div>
60
+ ```
61
+
62
+ You can write whatever markup you would like inside a template file. The most important thing is to include a `{{ template.content }}` tag. This destinates where your content will be rendered.
63
+
64
+
65
+ ### Using a template block
66
+
67
+ After creating our `awesome.html` template, we can use it in any of our Jekyll pages (or posts… heck even in `_include` files).
68
+
69
+ For this example, let's add it to our `index.md` file:
70
+
71
+ ```markdown
72
+ # Hello
73
+ {% template awesome.html %}
74
+ I am content!
75
+ {% endtemplate %}
76
+ ```
77
+
78
+ Your template content needs to begin with `{% template %}` and end with `{% endtemplate %}`. Be sure to include the path/name of the template file you wish to use.
79
+
80
+ The final rendered `.html` will look like this:
81
+
82
+ ```html
83
+ <h1 id="hello">Hello</h1>
84
+ <div class="awesome"> <p>I am content!</p> </div>
85
+ ```
86
+
87
+
88
+ ## Rendering template content as HTML
89
+
90
+ By default, templates parse and render content as **markdown**. To force templates to render content as HTML, all the `parse: "html"` attribute to your `{% template %}` tag.
91
+
92
+ ```markdown
93
+ {% template awesome.html parse: "html" %}
94
+ # Title
95
+ I am content! As HTML!
96
+ {% endtemplate %}
97
+ ```
98
+
99
+ The final rendered `.html` will look like this:
100
+
101
+ ```html
102
+ <div class="awesome"> # Title I am content! As HTML! </div>
103
+ ```
104
+
105
+
106
+
107
+ ## Using YAML front matter
108
+
109
+ You can add YAML front matter to both your template files, just like Jekyll pages and posts.
110
+
111
+ ```
112
+ ---
113
+ title: Awesome title
114
+ ---
115
+ <div class="awesome">
116
+ <h1>{{ template.title</h1>
117
+
118
+ {{ template.content }}
119
+ </div>
120
+ ```
121
+
122
+ Front matter can also be defined in your `{% template %}` block. Any front matter data defined here will override the data defined in your original template.
123
+
124
+ ```
125
+ {% template awesome.html %}
126
+ ---
127
+ title: Best title
128
+ ---
129
+ I am content!
130
+ {% endtemplate %}
131
+ ```
132
+
133
+ ```html
134
+ <div class="awesome">
135
+ <h1>Best title</h1>
136
+ <p>I am content!</p>
137
+ </div>
138
+ ```
139
+
140
+
141
+ ## Using templates within templates
142
+
143
+ Yo dawg. I heard you liked templates! The template block supports nesting 👏
144
+
145
+ ```markdown
146
+ {% template outer.html %}
147
+ {% template inner.html %}
148
+ Hi!
149
+ {% endtemplate %}
150
+ {% endtemplate %}
151
+ ```
152
+
153
+
154
+ ---
155
+
156
+
157
+ More documentation coming soon!
158
+
159
+
160
+ ---
161
+
162
+
163
+ ## Note
164
+
165
+ I am **not** a Ruby developer. (My background is mostly with Javascript). I wrote this plugin based on experimentation and combing through [Jekyll's](https://github.com/jekyll/jekyll) and [Liquid's](https://github.com/Shopify/liquid) source code + documentation. I'm sure there's probably code in there somewhere that's offensive to Ruby devs.
166
+
167
+ We've been using `{% template %}` for many months now on the [Help Scout website](https://www.helpscout.net/), and it's been working great! We haven't noticed any slowdowns in build times (and we use **a lot** of templates).
data/Rakefile CHANGED
@@ -1,6 +1,16 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'rdoc'
5
+ require 'date'
6
+ require 'yaml'
7
+ require 'rake/testtask'
3
8
 
4
- RSpec::Core::RakeTask.new(:spec)
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[lib]))
10
+ require 'jekyll/version'
5
11
 
6
- task :default => :spec
12
+ Rake::TestTask.new(:test) do |test|
13
+ test.libs << 'lib' << 'test'
14
+ test.pattern = 'test/**/test_*.rb'
15
+ test.verbose = true
16
+ end
@@ -26,5 +26,10 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.13"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
29
- spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "minitest-reporters"
30
+ spec.add_development_dependency "minitest-profile"
31
+ spec.add_development_dependency "minitest", "~> 5.8"
32
+ spec.add_development_dependency "rspec-mocks"
33
+ spec.add_development_dependency "shoulda"
34
+ spec.add_development_dependency "kramdown"
30
35
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Template
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ItsJonQ
@@ -81,19 +81,89 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rspec
84
+ name: minitest-reporters
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest-profile
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
115
  - - "~>"
88
116
  - !ruby/object:Gem::Version
89
- version: '3.0'
117
+ version: '5.8'
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
122
  - - "~>"
95
123
  - !ruby/object:Gem::Version
96
- version: '3.0'
124
+ version: '5.8'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-mocks
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: shoulda
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: kramdown
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
97
167
  description:
98
168
  email:
99
169
  - itsjonq@gmail.com