Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use ENV variables for switch_theme

  • Loading branch information...
commit 9bd0deabd4d1dba78194b68e0d4e2c3f3853eddb 1 parent 2402716
@plusjade plusjade authored
Showing with 7 additions and 5 deletions.
  1. +7 −5 Rakefile
View
12 Rakefile
@@ -57,17 +57,19 @@ task :page do
end # task :page
desc "Switch between Jekyll-bootstrap themes."
-task :switch_theme, :theme do |t, args|
- theme_path = File.join(CONFIG['themes'], args.theme)
+task :switch_theme do
+ theme_name = ENV["name"].to_s
+ theme_path = File.join(CONFIG['themes'], theme_name)
settings_file = File.join(theme_path, "settings.yml")
non_layout_files = ["settings.yml"]
- abort("rake aborted: '#{CONFIG['themes']}/#{args.theme}' directory not found.") unless FileTest.directory?(theme_path)
+ abort("rake aborted: name cannot be blank") if theme_name.empty?
+ abort("rake aborted: '#{theme_path}' directory not found.") unless FileTest.directory?(theme_path)
abort("rake aborted: '#{CONFIG['layouts']}' directory not found.") unless FileTest.directory?(CONFIG['layouts'])
Dir.glob("#{theme_path}/*") do |filename|
next if non_layout_files.include?(File.basename(filename).downcase)
- puts "Generating '#{args.theme}' layout: #{File.basename(filename)}"
+ puts "Generating '#{theme_name}' layout: #{File.basename(filename)}"
open(File.join(CONFIG['layouts'], File.basename(filename)), 'w') do |page|
if File.basename(filename, ".html").downcase == "default"
@@ -80,7 +82,7 @@ task :switch_theme, :theme do |t, args|
page.puts "---"
end
page.puts "{% include JB/setup %}"
- page.puts "{% include themes/#{args.theme}/#{File.basename(filename)} %}"
+ page.puts "{% include themes/#{theme_name}/#{File.basename(filename)} %}"
end
end
end # task :switch_theme
Please sign in to comment.
Something went wrong with that request. Please try again.