diff options
author | Jade Dominguez <plusjade@gmail.com> | 2011-12-30 14:17:44 -0800 |
---|---|---|
committer | Jade Dominguez <plusjade@gmail.com> | 2012-01-11 15:13:40 -0800 |
commit | 4c18e3c136bea49e3335ab594ae22d999892cf27 (patch) | |
tree | 6ee24ea94d767bc6c69081531350a6776a5f9fcb /_plugins |
version 0.0.1
Diffstat (limited to '_plugins')
-rw-r--r-- | _plugins/debug.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/_plugins/debug.rb b/_plugins/debug.rb new file mode 100644 index 0000000..e1dde39 --- /dev/null +++ b/_plugins/debug.rb @@ -0,0 +1,38 @@ +# A simple way to inspect liquid template variables. +# Usage: +# Can be used anywhere liquid syntax is parsed (templates, includes, posts/pages) +# {{ site | debug }} +# {{ site.posts | debug }} +# +require 'pp' +module Jekyll + # Need to overwrite the inspect method here because the original + # uses < > to encapsulate the psuedo post/page objects in which case + # the output is taken for HTML tags and hidden from view. + # + class Post + def inspect + "#Jekyll:Post @id=#{self.id.inspect}" + 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)
\ No newline at end of file |