Sha256: 48d146953aded24749e176dda123cc9530b53acb2a9f119061d992ab6393558b

Contents?: true

Size: 1.53 KB

Versions: 23

Compression:

Stored size: 1.53 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/debug.rb
# Helper to inspect liquid template variables for Jekyll
#
# Product/Info:
# http://jekyll.one
#
# Copyright (C) 2020 Juergen Adams
#
# J1 Template is licensed under the MIT License.
# See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE
#
# ------------------------------------------------------------------------------
#  USAGE:
#  Can be used anywhere liquid syntax is parsed with templates, includes,
#   posts and pages:
#
#    {{ site | debug }}
#    {{ site.pages | debug }}
#    {{ site.posts | debug }}
#
# ------------------------------------------------------------------------------
require 'pp'

module Jekyll
  # Need to overwrite the inspect method here because the original
  # uses < > to encapsulate the pseudo post/page objects in which case
  # the output is taken for HTML tags and hidden from view.
  #

  # <= Jekyll 2.5.3
  class Post
    def inspect
      "#Jekyll:Post @id=#{self.id.inspect}"
    end
  end

  # >= Jekyll 3.0.0
  class Document
    def inspect
      "#Jekyll::Document #{relative_path} collection=#{collection.label}"
    end
  end

  class Page
    def inspect
      "#Jekyll::Page @name=#{self.name.inspect}"
    end
  end
end # Jekyll

module Jekyll
  module DebugFilter

    def debug(obj, stdout=false)
      puts obj.pretty_inspect if stdout
      "<pre>#{obj.class}\n#{obj.pretty_inspect}</pre>"
    end

  end # DebugFilter
end # Jekyll

Liquid::Template.register_filter(Jekyll::DebugFilter)

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
j1-template-2020.0.22 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.21 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.20 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.19 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.18 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.17 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.16 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.15 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.14 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.13 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.12 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.11 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.10 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.9 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.8 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.7 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.6 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.5 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.4 lib/starter_web/_plugins/debug.rb
j1-template-2020.0.3 lib/starter_web/_plugins/debug.rb