Class: DraftPageBase
- Inherits:
-
JekyllSupport::JekyllBlock
- Object
- JekyllSupport::JekyllBlock
- DraftPageBase
- Defined in:
- lib/jekyll_draft/other_page/if_draft.rb
Overview
Jekyll block tags that detect draft documents
Direct Known Subclasses
Constant Summary collapse
- IF_DRAFT =
'if_page_draft'.freeze
- UNLESS_DRAFT =
'unless_page_draft'.freeze
- VERSION =
DraftVersion::VERSION.freeze
Instance Method Summary collapse
-
#render_impl(content) ⇒ Object
Content has a true clause, and optionally might have an else clause Clauses can reference two variables: path_portion and matched_page path_portion is specified as the sole argument to this block tag matched_path is the APage with an href that uniquely includes path_portion, or nil if no matching APage was found.
Instance Method Details
#render_impl(content) ⇒ Object
Content has a true clause, and optionally might have an else clause Clauses can reference two variables: path_portion and matched_page
path_portion is specified as the sole argument to this block tag
matched_path is the APage with an href that uniquely includes path_portion,
or nil if no matching APage was found
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jekyll_draft/other_page/if_draft.rb', line 12 def render_impl(content) true_content, false_content, extra_content = content.split(RECORD_SEPARATOR) raise DraftError, 'Warning: More than one else clause detected' if extra_content @path_portion = @argument_string.strip raise DraftError, 'Error: path_portion was not specified' unless @path_portion configure @matched_page = if @path_portion.start_with?('#') @page else Jekyll::Draft.page_match(@path_portion, error_if_no_match: @error_if_no_match, verify_unique_match: @verify_unique_match) end raise DraftError, "Error: path_portion='#{@path_portion}' does not specify a local page." if @matched_page == :non_local_url is_draft = Jekyll::Draft.draft? @matched_page clause_value = if @tag_name == IF_DRAFT is_draft ? true_content : false_content else # UNLESS_DRAFT is_draft ? false_content : true_content end process_variables clause_value rescue StandardError => e msg = e. if msg.length < 250 @logger.error { msg } else @logger.error { "#{msg[0..125]} ... #{msg[-125..msg.length]}" } end exit! end |