From f2e96ac168a0c1a6c180feaa3d043e2cc4fa8ed0 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Tue, 22 May 2012 16:28:56 -0500 Subject: [PATCH] Added documentation for puts plugin --- source/docs/blogging/plugins/index.markdown | 11 +++++ source/docs/plugins/puts/index.markdown | 53 +++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 source/docs/plugins/puts/index.markdown diff --git a/source/docs/blogging/plugins/index.markdown b/source/docs/blogging/plugins/index.markdown index 48a71d6..463b137 100644 --- a/source/docs/blogging/plugins/index.markdown +++ b/source/docs/blogging/plugins/index.markdown @@ -73,4 +73,15 @@ Import files on your file system into any blog post or page. For example, to emb [Examples & documentation »](/docs/plugins/render-partial/) +## Puts +Puts is a Liquid block which outputs its contents to your terminal with Ruby's `puts` command. This really handy when you're working on a Liquid tag or a Jekyll plugin and you want to to be able to peek behind the curtain at what Liquid sees. + +{% raw %} + {% for post in site.posts reverse %} + {% puts %}{{ post.title }}{% endputs %} + {% endfor %} +{% endraw %} + +[Examples & documentation »](/docs/plugins/puts/) + Also see the [Octopress Plugin index](/docs/plugins) for the full list of Octopress plugins. diff --git a/source/docs/plugins/puts/index.markdown b/source/docs/plugins/puts/index.markdown new file mode 100644 index 0000000..d858177 --- /dev/null +++ b/source/docs/plugins/puts/index.markdown @@ -0,0 +1,53 @@ +--- +layout: page +title: "Puts - log from Liquid to the terminal" +date: 2011-07-22 09:14 +sidebar: false +footer: false +--- + +Puts is a Liquid block which outputs its contents to your terminal with Ruby's `puts` command. This really handy when you're working on a Liquid tag or a Jekyll plugin and you want to to be able to peek behind the curtain at what Liquid sees. + +#### Syntax + + {% puts %}Optional Text: {{ some_liquid_variable }}{% endputs %} + +This just outputs the contents of the block to the terminal. Note: Markdown, Textile and other converters run after liquid, so you'll see raw templating markup, not processed html. + +#### Example 1 + + {% for post in site.posts %} + {% puts %}Title: {{ post.title }}{% endputs %} + {% endfor %} + +#### Output: + +``` +{% puts %} Title: Hello World, I just switched to Octopress +{% puts %} Title: Zombie Ninjas Attack: A survivor's retrospective +... +``` + +#### Example 2 - Longer content +If a line of output is wider than 80 characters it gets output in a puts block for easier marking. + + {% for post in site.posts %} + {% puts %} + Title: {{ post.title }} + Content: {{ post.content }} + {% endputs %} + {% endfor %} + +#### Output + +``` +{% puts %} +Title: Zombie Ninjas Attack: A survivor's retrospective +Content: Spoiler: You don't want to survive this. So there I was, standing in line +for a movie. I could hear hear some car alarms going off in the distance, but that +.... +{% endputs %} +... +``` + +[« Plugins page](/docs/plugins)