Skip to content

Commit

Permalink
Do not bundle with debug flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed Aug 11, 2013
1 parent 21f119e commit 2859776
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/jekyll/assets_plugin/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,25 @@ def render_asset_path
def render_javascript
@path << ".js" if File.extname(@path).empty?

if @site.assets_config.debug
return @site.assets[@path].to_a.map{ |a|
JAVASCRIPT % @site.asset_path(a.logical_path, :bundle => false)
}.join("\n")
end

JAVASCRIPT % render_asset_path
end


def render_stylesheet
@path << ".css" if File.extname(@path).empty?

if @site.assets_config.debug
return @site.assets[@path].to_a.map{ |a|
STYLESHEET % @site.asset_path(a.logical_path, :bundle => false)
}.join("\n")
end

STYLESHEET % render_asset_path
end

Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/_assets/vapor.css.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//= require wowstyle
/* vapor css framework */

@font-face {
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/_assets/vapor.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//= require wowscript
/* vapor js framework */
Empty file.
Empty file.
56 changes: 56 additions & 0 deletions spec/lib/jekyll/assets_plugin/renderer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# stdlib
require "ostruct"


require "spec_helper"


module Jekyll::AssetsPlugin
describe Renderer do

let(:site) do
Jekyll::Site.new Jekyll.configuration({
"source" => fixtures_path.to_s,
"destination" => @dest.to_s,
"assets" => assets_config
})
end


let(:renderer) do
context = OpenStruct.new(:registers => { :site => site })
Renderer.new context, "app"
end


describe "#render_javascript" do
subject { renderer.render_javascript }

context "when debug mode enabled" do
let(:assets_config){ Hash[:debug, true] }
it { should match %r{^(\s*<script src="[^"]+"></script>\s*){3}$} }
end

context "when debug mode disabled" do
let(:assets_config){ Hash[:debug, false] }
it { should match %r{^(\s*<script src="[^"]+"></script>\s*){1}$} }
end
end


describe "#render_stylesheet" do
subject { renderer.render_stylesheet }

context "when debug mode enabled" do
let(:assets_config){ Hash[:debug, true] }
it { should match %r{^(\s*<link rel="stylesheet" href="[^"]+">\s*){3}$} }
end

context "when debug mode disabled" do
let(:assets_config){ Hash[:debug, false] }
it { should match %r{^(\s*<link rel="stylesheet" href="[^"]+">\s*){1}$} }
end
end

end
end

0 comments on commit 2859776

Please sign in to comment.