jekyll-assets 0.7.1 → 0.7.2
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.
- data/HISTORY.md +5 -0
- data/README.md +2 -0
- data/lib/jekyll/assets_plugin/filters.rb +1 -1
- data/lib/jekyll/assets_plugin/renderer.rb +6 -0
- data/lib/jekyll/assets_plugin/tag.rb +1 -1
- data/lib/jekyll/assets_plugin/version.rb +1 -1
- data/spec/lib/jekyll/assets_plugin/filters_spec.rb +17 -0
- data/spec/lib/jekyll/assets_plugin/tag_spec.rb +17 -0
- metadata +3 -3
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -77,6 +77,7 @@ Once plugin installed, you'll have following Liquid tags available:
|
|
77
77
|
|
78
78
|
- `{% javascript app %}`: Generates `<script>` tag for `app.js`
|
79
79
|
- `{% stylesheet app %}`: Generates `<link>` tag for `app.css`
|
80
|
+
- `{% image logo.png %}`: Generates `<img>` tag for `logo.png`
|
80
81
|
- `{% asset_path logo.png %}`: Returns _resulting_ URL for `logo.png`
|
81
82
|
- `{% asset app.css %}`: Returns _compiled_ body of `app.css`
|
82
83
|
|
@@ -84,6 +85,7 @@ Also you'll have complimentary Liquid filters as well:
|
|
84
85
|
|
85
86
|
- `{{ 'app' | javascript }}`: Generates `<script>` tag for `app.js`
|
86
87
|
- `{{ 'app' | stylesheet }}`: Generates `<link>` tag for `app.css`
|
88
|
+
- `{{ 'logo.png' | image }}`: Generates `<img>` tag for `logo.png`
|
87
89
|
- `{{ 'logo.png' | asset_path }}`: Returns _resulting_ URL for `logo.png`
|
88
90
|
- `{{ 'app.css' | asset }}`: Returns _compiled_ body of `app.css`
|
89
91
|
|
@@ -6,7 +6,7 @@ module Jekyll
|
|
6
6
|
module AssetsPlugin
|
7
7
|
module Filters
|
8
8
|
|
9
|
-
%w{ asset asset_path javascript stylesheet }.each do |name|
|
9
|
+
%w{ asset asset_path image javascript stylesheet }.each do |name|
|
10
10
|
module_eval <<-RUBY, __FILE__, __LINE__
|
11
11
|
def #{name} path # def stylesheet logical_path
|
12
12
|
r = Renderer.new @context, path # r = Renderer.new @context, path
|
@@ -4,6 +4,7 @@ module Jekyll
|
|
4
4
|
|
5
5
|
STYLESHEET = '<link rel="stylesheet" href="%s">'
|
6
6
|
JAVASCRIPT = '<script src="%s"></script>'
|
7
|
+
IMAGE = '<img src="%s">'
|
7
8
|
|
8
9
|
|
9
10
|
def initialize context, logical_path
|
@@ -34,6 +35,11 @@ module Jekyll
|
|
34
35
|
end
|
35
36
|
|
36
37
|
|
38
|
+
def render_image
|
39
|
+
render_tag IMAGE
|
40
|
+
end
|
41
|
+
|
42
|
+
|
37
43
|
protected
|
38
44
|
|
39
45
|
|
@@ -9,6 +9,23 @@ module Jekyll::AssetsPlugin
|
|
9
9
|
Liquid::Template.parse(content).render({}, context)
|
10
10
|
end
|
11
11
|
|
12
|
+
context "{{ '<file>' | image }}" do
|
13
|
+
def tag_re name
|
14
|
+
file = "/assets/#{name}-[a-f0-9]{32}\.png"
|
15
|
+
Regexp.new "^#{Renderer::IMAGE % file}$"
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when <file> exists" do
|
19
|
+
subject { render("{{ 'noise.png' | image }}") }
|
20
|
+
it { should match tag_re("noise") }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when <file> does not exists" do
|
24
|
+
subject { render("{{ 'not-found.png' | image }}") }
|
25
|
+
it { should match "Liquid error: Couldn't find file 'not-found.png'" }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
12
29
|
context "{{ '<file>' | stylesheet }}" do
|
13
30
|
def tag_re name
|
14
31
|
file = "/assets/#{name}-[a-f0-9]{32}\.css"
|
@@ -9,6 +9,23 @@ module Jekyll::AssetsPlugin
|
|
9
9
|
Liquid::Template.parse(content).render({}, context)
|
10
10
|
end
|
11
11
|
|
12
|
+
context "{% image <file> %}" do
|
13
|
+
def tag_re name
|
14
|
+
file = "/assets/#{name}-[a-f0-9]{32}\.png"
|
15
|
+
Regexp.new "^#{Renderer::IMAGE % file}$"
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when <file> exists" do
|
19
|
+
subject { render("{% image noise.png %}") }
|
20
|
+
it { should match tag_re("noise") }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when <file> does not exists" do
|
24
|
+
subject { render("{% image not-found.png %}") }
|
25
|
+
it { should match "Liquid error: Couldn't find file 'not-found.png'" }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
12
29
|
context "{% stylesheet <file> %}" do
|
13
30
|
def tag_re name
|
14
31
|
file = "/assets/#{name}-[a-f0-9]{32}\.css"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jekyll
|
@@ -249,7 +249,7 @@ rubyforge_project:
|
|
249
249
|
rubygems_version: 1.8.23
|
250
250
|
signing_key:
|
251
251
|
specification_version: 3
|
252
|
-
summary: jekyll-assets-0.7.
|
252
|
+
summary: jekyll-assets-0.7.2
|
253
253
|
test_files:
|
254
254
|
- spec/fixtures/.gitignore
|
255
255
|
- spec/fixtures/_assets/app.css.erb
|