10000 Backport #9680 for v4.3.x: Render theme-gem root only in development by ashmaroli · Pull Request #9684 · jekyll/jekyll · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Backport #9680 for v4.3.x: Render theme-gem root only in development #9684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/_data/jekyll_variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ page:

theme:
- name: theme.root
description: Absolute path to the theme-gem.
description: >-
Absolute path to the theme-gem. Rendered only when environment variable <code>JEKYLL_ENV</code>
is set to <code>development</code>.
- name: theme.authors
description: Comma separated string composed of the authors of the theme-gem.
- name: theme.description
Expand Down
5 changes: 4 additions & 1 deletion lib/jekyll/drops/theme_drop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion test/test_theme_drop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,30 @@ 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|
assert @drop.key?(key)
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
Loading
0