mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-12-25 00:48:53 -05:00
added puts plugin for easily logging from liquid templates to the terminal
This commit is contained in:
parent
ba98467538
commit
aed317d92b
32
plugins/puts.rb
Normal file
32
plugins/puts.rb
Normal file
@ -0,0 +1,32 @@
|
||||
# Title: Puts Tag for Jekyll
|
||||
# Author: Brandon Mathis http://brandonmathis.com
|
||||
# Description: Puts is a liquid tag block which outputs its contents to the terminal
|
||||
#
|
||||
# Example Usage:
|
||||
# Lets say you've assigned some variable you need to test.
|
||||
# {% assign noun = "toaster" %}
|
||||
#
|
||||
# Drop it in a puts block along with a way to identify it in the output.
|
||||
# {% puts %}
|
||||
# Look out he's got a {{ noun }}.
|
||||
# {% endputs %}
|
||||
#
|
||||
# Outputs:
|
||||
# >>> {% puts %} <<<
|
||||
# Look out he's got a toaster.
|
||||
#
|
||||
|
||||
module Jekyll
|
||||
class Puts < Liquid::Block
|
||||
def initialize(tag_name, markup, tokens)
|
||||
super
|
||||
end
|
||||
|
||||
def render(context)
|
||||
puts ">>> {% puts %} <<<"
|
||||
puts super.map(&:strip).join
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('puts', Jekyll::Puts)
|
Loading…
Reference in New Issue
Block a user