jekyll/jekyll — pull request #2901 by nitoyon (2014-09-10 14:41:31+00:00)
Title: Expose page.unrendered_content and page.rendered_content to Liquid

## Problem

In Liquid template, `page.content` variable represents both un-rendered content and rendered content (e.g. un-rendered content = `[Jekyll](http://jekyllrb.com)`, rendered content = `

Jekyll

`).

This behaviour is documented [as follows](http://jekyllrb.com/docs/variables/):

The content of the Page, rendered or un-rendered depending upon what Liquid is being processed and what page is.

By further code reading, I found how to refer to (un)rendered content.

| un-rendered content| rendered content
---------------------------|--------------------|--------------------------------------
un-rendered page | `page.content` | impossible
rendered & layouting page | `page.content` | `content` (If the page is already wrapped by other layout file, `content` isn't equal to rendered content)
rendered & layouted page | ---- | `page.content`

It would be useful if we could get (un)rendered content anytime.

For example, I want to embed `` tag to my new site generated by `jekyll new` command.

* Adding `` to `_include/head.html` isn't good because `og:description` contains site name and post date.
* add `` to `_include/head.html` isn't good because `og:description` contains raw markdown document.

I need a new Liquid variable to embed rendered content.

## Solution

I exposed `page.unrenderd_content` and `page.rendered_content` variable to Liquid. Now, it becomes obvious how to use (un)rendered content.

| un-rendered content | rendered content
---------------------------|------------------------|----------------------------------
un-rendered page | page.unrenderd_content | page.rendered_content (== nil)
rendered & layouting page | page.unrenderd_content | page.rendered_content
rendered & layouted page | page.unrenderd_content | page.rendered_content

The behavior of `page.content` isn't changed in order to keep the backward compatibility.