Sha256: dd9d066ff089131a1a01f37aebfffb527c5ccb6ea1e4a86c9f99952de70fdee9

Contents?: true

Size: 1.52 KB

Versions: 35

Compression:

Stored size: 1.52 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/debug.rb
# Helper to inspect liquid template variables for Jekyll
#
# Product/Info:
# http://jekyll.one
#
# Copyright (C) 2023 Juergen Adams
#
# J1 Theme is licensed under the MIT License.
# See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md
# ------------------------------------------------------------------------------
#  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

35 entries across 35 versions & 1 rubygems

Version Path
j1-template-2023.4.4 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.4.3 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.4.2 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.4.1 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.4.0 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.3.3 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.3.2 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.3.1 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.3.0 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.2.7 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.2.6 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.2.5 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.2.4 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.2.3 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.2.2 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.2.1 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.2.0 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.1.0 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.0.17 lib/starter_web/_plugins/filter/debug.rb
j1-template-2023.0.16 lib/starter_web/_plugins/filter/debug.rb