Sha256: da862d46a09fa4b84daec0810b6f4a5e930fd05de216cce38a49b0664f79153a

Contents?: true

Size: 914 Bytes

Versions: 2

Compression:

Stored size: 914 Bytes

Contents

# 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 Octopress
  class Puts < Liquid::Block
    def initialize(tag_name, markup, tokens)
      super
    end

    def render(context)
      # Use a block if label + output is wider than 80 characters
      if super.length > 69
        puts "{% puts %}"
        puts super
        puts "{% endputs %}"
      else
        puts "{% puts %} #{super}"
      end
    end
  end
end

Liquid::Template.register_tag('puts', Octopress::Puts)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
octopress-3.0.0.alpha2 lib/octopress/tags/puts.rb
octopress-3.0.0.alpha1 lib/octopress/tags/puts.rb