Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the collection label to a document's data #2436

Merged
merged 10 commits into from
Jun 4, 2014
1 change: 1 addition & 0 deletions History.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Add categories, last build datetime, and generator to site template
feed (#2438)
* Configurable, replaceable Logger-compliant logger (#2444)
* Extract `gist` tag into a separate gem (#2469)

### Bug Fixes

Expand Down
3 changes: 2 additions & 1 deletion lib/jekyll/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ def to_liquid
"content" => content,
"path" => path,
"relative_path" => relative_path,
"url" => url
"url" => url,
"collection" => collection.label
}
else
data
Expand Down
10 changes: 10 additions & 0 deletions site/docs/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ In addition to any YAML front-matter provided in the document's corresponding fi
</p>
</td>
</tr>
<tr>
<td>
<p><code>collection</code></p>
</td>
<td>
<p>
The name of the document's collection.
</p>
</td>
</tr>
</tbody>
</table>
</div>
4 changes: 4 additions & 0 deletions test/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class TestDocument < Test::Unit::TestCase
}, @document.data)
end

should "output the collection name in the #to_liquid method" do
assert_equal @document.to_liquid['collection'], "methods"
end

end

context " a document part of a rendered collection" do
Expand Down