diff --git a/bridgetown-core/features/rendering.feature b/bridgetown-core/features/rendering.feature index 334aee1c5..df57d97c9 100644 --- a/bridgetown-core/features/rendering.feature +++ b/bridgetown-core/features/rendering.feature @@ -137,19 +137,17 @@ Feature: Rendering And I should see "Hi there, John Doe!" in "output/index.html" And I should not see "Build Warning:" in the build output - Scenario: Execute inline Ruby if ENV is set + Scenario: Execute inline Ruby Given I have a _posts directory And I have the following post: | title | date | layout | cool | content | | Page | 2020-01-01 | simple | !ruby/string:Rb \|\n "Very" + " Cool".upcase | Something {{ page.cool }} | And I have a "index.html" page with layout "simple" that contains "{% for post in site.posts %}{{ post.content }}{% endfor %}" And I have a simple layout that contains "{{ content }}" - And I have an env var BRIDGETOWN_RUBY_IN_FRONT_MATTER set to true When I run bridgetown build - And I delete the env var BRIDGETOWN_RUBY_IN_FRONT_MATTER Then I should see "Very COOL" in "output/index.html" - Scenario: Don't execute inline Ruby if ENV is not set + Scenario: Don't execute inline Ruby if ENV is set to false Given I have a _posts directory And I have the following post: | title | date | layout | cool | content | @@ -181,7 +179,5 @@ Feature: Rendering | Page | 2020-01-01 | simple | #\n nested_cool: !ruby/string:Rb \|\n "Very Very" + " Cool".upcase | Something {{ page.cool.nested_cool }} | And I have a "index.html" page with layout "simple" that contains "{% for post in site.posts %}{{ post.content }}{% endfor %}" And I have a simple layout that contains "{{ content }}" - And I have an env var BRIDGETOWN_RUBY_IN_FRONT_MATTER set to true When I run bridgetown build - And I delete the env var BRIDGETOWN_RUBY_IN_FRONT_MATTER Then I should see "Very Very COOL" in "output/index.html" diff --git a/bridgetown-core/lib/bridgetown-core/concerns/site/renderable.rb b/bridgetown-core/lib/bridgetown-core/concerns/site/renderable.rb index 5bb580476..3ae0dbfef 100644 --- a/bridgetown-core/lib/bridgetown-core/concerns/site/renderable.rb +++ b/bridgetown-core/lib/bridgetown-core/concerns/site/renderable.rb @@ -17,8 +17,7 @@ def render Bridgetown::Hooks.trigger :site, :post_render, self, payload end - # Executes inline Ruby frontmatter if - # +ENV+["BRIDGETOWN_RUBY_IN_FRONTMATTER"] equals "true" + # Executes inline Ruby frontmatter # # @example # calculation: !ruby/string:Rb | diff --git a/bridgetown-core/lib/bridgetown-core/configuration.rb b/bridgetown-core/lib/bridgetown-core/configuration.rb index 957864099..3c06cddbf 100644 --- a/bridgetown-core/lib/bridgetown-core/configuration.rb +++ b/bridgetown-core/lib/bridgetown-core/configuration.rb @@ -35,7 +35,7 @@ class Configuration < ActiveSupport::HashWithIndifferentAccess "limit_posts" => 0, "future" => false, "unpublished" => false, - "ruby_in_front_matter" => true, # requires BRIDGETOWN_RUBY_IN_FRONT_MATTER == "true" + "ruby_in_front_matter" => true, # Conversion "markdown" => "kramdown", @@ -276,7 +276,7 @@ def add_default_excludes end def should_execute_inline_ruby? - ENV["BRIDGETOWN_RUBY_IN_FRONT_MATTER"] == "true" && + ENV["BRIDGETOWN_RUBY_IN_FRONT_MATTER"] != "false" && self["ruby_in_front_matter"] end diff --git a/bridgetown-website/src/_docs/configuration/options.md b/bridgetown-website/src/_docs/configuration/options.md index 7a69c440d..704182b2d 100644 --- a/bridgetown-website/src/_docs/configuration/options.md +++ b/bridgetown-website/src/_docs/configuration/options.md @@ -218,6 +218,15 @@ a staging area and copy files from there to your web server.

--unpublished

+ + +

Ruby Front Matter

+

Process Ruby front matter (default true)

+ + +

ruby_in_front_matter: BOOL

+ +

LSI

diff --git a/bridgetown-website/src/_docs/front-matter.md b/bridgetown-website/src/_docs/front-matter.md index f89637099..40087fcf9 100644 --- a/bridgetown-website/src/_docs/front-matter.md +++ b/bridgetown-website/src/_docs/front-matter.md @@ -230,7 +230,7 @@ you may encounter build errors. For advanced use cases where you wish to generate dynamic values for front matter variables, you can use Ruby Front Matter (new in Bridgetown v0.13). This feature is available for pages, posts, and other documents–as well as layouts for site-wide access to your Ruby return values. {% rendercontent "docs/note" %} -This requires the environment variable `BRIDGETOWN_RUBY_IN_FRONT_MATTER` to be set to `"true"` in your development and deployment setups. Otherwise the code will not be executed and will be treated as a raw string. +Prior to v0.17, this required the environment variable `BRIDGETOWN_RUBY_IN_FRONT_MATTER` to be set to `"true"`, otherwise the code would not be executed and would be treated as a raw string. {% endrendercontent %} [Here's a blog post with a high-level overview](/feature/supercharge-your-bridgetown-site-with-ruby-front-matter/){:data-no-swup="true"} of what Ruby Front Matter is capable of and why you might want to use it.