Skip to content

Commit

Permalink
Merge pull request #93 from tomdiggle/master
Browse files Browse the repository at this point in the history
Fix Liquid tag generates no space between attributes
  • Loading branch information
ixti committed Aug 5, 2014
2 parents 71b3e6f + ad0ac68 commit d1905d5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/jekyll/assets_plugin/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def initialize(context, logical_path)
@path = logical_path.strip

@path, _, @attrs = @path.partition(" ") if @path[" "]
@attrs.prepend(" ") if @attrs
end

def render_asset
Expand Down
30 changes: 24 additions & 6 deletions spec/lib/jekyll/assets_plugin/tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,45 @@ def render_tag(template, path, attrs = "")
end

context "{% image <file> %}" do
def tag_re(name)
def tag_re(name, attrs = "")
file = "/assets/#{name}-[a-f0-9]{32}\.png"
Regexp.new "^#{render_tag :IMAGE, file}$"
attrs.prepend(" ") unless attrs.empty?
Regexp.new "^#{render_tag :IMAGE, file, attrs}$"
end

context "when <file> exists" do
subject { render("{% image noise.png %}") }
it { is_expected.to match tag_re("noise") }
end

context "when <file> has an attribute" do
subject { render("{% image noise.png alt=\"Foobar\" %}") }
it { is_expected.to match tag_re("noise", "alt=\"Foobar\"") }
end

context "when <file> does not exists" do
subject { render("{% image not-found.png %}") }
it { is_expected.to match not_found_error "not-found.png" }
end
end

context "{% stylesheet <file> %}" do
def tag_re(name)
def tag_re(name, attrs = "")
file = "/assets/#{name}-[a-f0-9]{32}\.css"
Regexp.new "^#{render_tag :STYLESHEET, file}$"
attrs.prepend(" ") unless attrs.empty?
Regexp.new "^#{render_tag :STYLESHEET, file, attrs}$"
end

context "when <file> exists" do
subject { render("{% stylesheet app.css %}") }
it { is_expected.to match tag_re("app") }
end

context "when <file> has an attribute" do
subject { render("{% stylesheet app.css type=\"text/css\" %}") }
it { is_expected.to match tag_re("app", "type=\"text/css\"") }
end

context "when <file> name has multiple dots" do
subject { render("{% stylesheet app.min %}") }
it { is_expected.to match tag_re("app.min") }
Expand All @@ -61,16 +73,22 @@ def tag_re(name)
end

context "{% javascript <file> %}" do
def tag_re(name)
def tag_re(name, attrs = "")
file = "/assets/#{name}-[a-f0-9]{32}\.js"
Regexp.new "^#{render_tag :JAVASCRIPT, file}$"
attrs.prepend(" ") unless attrs.empty?
Regexp.new "^#{render_tag :JAVASCRIPT, file, attrs}$"
end

context "when <file> exists" do
subject { render("{% javascript app.js %}") }
it { is_expected.to match tag_re("app") }
end

context "when <file> has an attribute" do
subject { render("{% javascript app.js type=\"text/javascript\" %}") }
it { is_expected.to match tag_re("app", "type=\"text/javascript\"") }
end

context "when <file> name has multiple dots" do
subject { render("{% javascript app.min %}") }
it { is_expected.to match tag_re("app.min") }
Expand Down

0 comments on commit d1905d5

Please sign in to comment.