Sha256: aa086e6c2e9793b83c4f17dad774f6273f0b77061ee0974f63fc27de0e7dfbe4

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

require 'jekyll_plugin_support'

# Jekyll block tags that detect draft documents
class DraftBase < JekyllSupport::JekyllBlock
  IF_DRAFT     = 'if_draft'.freeze
  UNLESS_DRAFT = 'unless_draft'.freeze
  VERSION      = DraftVersion::VERSION.freeze

  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
end

class IfDraft < DraftBase
  ::JekyllSupport::JekyllPluginHelper.register(self, IF_DRAFT)
end

class UnlessDraft < DraftBase
  ::JekyllSupport::JekyllPluginHelper.register(self, UNLESS_DRAFT)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll_draft-2.0.2 lib/if_draft.rb