diff --git a/docs/_data/jekyll_variables.yml b/docs/_data/jekyll_variables.yml
index d909a350..11822b4d 100644
--- a/docs/_data/jekyll_variables.yml
+++ b/docs/_data/jekyll_variables.yml
@@ -183,7 +183,9 @@ jekyll:
theme:
- name: theme.root
- description: Absolute path to the theme-gem.
+ description: >-
+ Absolute path to the theme-gem. Rendered only when environment variable JEKYLL_ENV
+ is set to development
.
- name: theme.authors
description: Comma separated string composed of the authors of the theme-gem.
- name: theme.description
diff --git a/lib/jekyll/drops/theme_drop.rb b/lib/jekyll/drops/theme_drop.rb
index b4625328..dd5b281a 100644
--- a/lib/jekyll/drops/theme_drop.rb
+++ b/lib/jekyll/drops/theme_drop.rb
@@ -3,9 +3,12 @@
module Jekyll
module Drops
class ThemeDrop < Drop
- delegate_methods :root
delegate_method_as :runtime_dependencies, :dependencies
+ def root
+ @root ||= ENV["JEKYLL_ENV"] == "development" ? @obj.root : ""
+ end
+
def authors
@authors ||= gemspec.authors.join(", ")
end
diff --git a/test/test_theme_drop.rb b/test/test_theme_drop.rb
index 6ebbcf88..cd2dd830 100644
--- a/test/test_theme_drop.rb
+++ b/test/test_theme_drop.rb
@@ -22,7 +22,7 @@ class TestThemeDrop < JekyllUnitTest
"dependencies" => [],
"description" => "This is a theme used to test Jekyll",
"metadata" => {},
- "root" => theme_dir,
+ "root" => "",
"version" => "0.1.0",
}
expected.each_key do |key|
@@ -30,5 +30,22 @@ class TestThemeDrop < JekyllUnitTest
assert_equal expected[key], @drop[key]
end
end
+
+ should "render gem root only in development mode" do
+ with_env("JEKYLL_ENV", nil) do
+ drop = fixture_site("theme" => "test-theme").to_liquid.theme
+ assert_equal "", drop["root"]
+ end
+
+ with_env("JEKYLL_ENV", "development") do
+ drop = fixture_site("theme" => "test-theme").to_liquid.theme
+ assert_equal theme_dir, drop["root"]
+ end
+
+ with_env("JEKYLL_ENV", "production") do
+ drop = fixture_site("theme" => "test-theme").to_liquid.theme
+ assert_equal "", drop["root"]
+ end
+ end
end
end