Class: DraftBase

Inherits:
JekyllSupport::JekyllBlock
  • Object
show all
Defined in:
lib/if_draft.rb

Overview

Jekyll block tags that detect draft documents

Direct Known Subclasses

IfDraft, UnlessDraft

Constant Summary collapse

IF_DRAFT =
'if_draft'.freeze
UNLESS_DRAFT =
'unless_draft'.freeze
VERSION =
DraftVersion::VERSION.freeze

Instance Method Summary collapse

Instance Method Details

#render_impl(content) ⇒ Object

Raises:



9
10
11
12
13
14
15
16
17
18
# File 'lib/if_draft.rb', line 9

def render_impl(content)
  true_value, false_value, extra = content.split(RECORD_SEPARATOR)
  raise DraftError, "Warning: More than one else clause detected" if extra

  if @tag_name == IF_DRAFT
    return ::Jekyll::Draft.draft?(@page) ? true_value : false_value
  end

  ::Jekyll::Draft.draft?(@page) ? false_value : true_value
end