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

[docs] Add information about finding a collection in `site.collections` #6165

Merged
merged 1 commit into from Jun 21, 2017

Conversation

Projects
None yet
7 participants
@adamvoss
Contributor

adamvoss commented Jun 21, 2017

Add information about finding a collection in site.collections. Information taken from the "Upgrading from 2.x to 3.x" page which was discovered by reading issue #4392.

@oe

oe approved these changes Jun 21, 2017

Show outdated Hide outdated docs/_docs/collections.md
@@ -309,6 +309,8 @@ you specified in your `_config.yml` (if present) and the following information:
you have a <code>_posts</code> directory or not. This is something to note
when iterating through <code>site.collections</code> as you may need to
filter it out.</p>
<p>You may wish to use filters to find your collection:
<code>site.collections | where: "label", "myCollection" | first</code></p>

This comment has been minimized.

@ashmaroli

ashmaroli Jun 21, 2017

Member

You forgot the braces..

- <code>site.collections | where: "label", "myCollection" | first</code>
+ <code>{{ site.collections | where: "label", "myCollection" | first }}</code>
@ashmaroli

ashmaroli Jun 21, 2017

Member

You forgot the braces..

- <code>site.collections | where: "label", "myCollection" | first</code>
+ <code>{{ site.collections | where: "label", "myCollection" | first }}</code>

This comment has been minimized.

@adamvoss

adamvoss Jun 21, 2017

Contributor

Added. I hadn't been sure if they were desired since the other nearby code blocks (that were just a variable or member access) didn't have them.

@adamvoss

adamvoss Jun 21, 2017

Contributor

Added. I hadn't been sure if they were desired since the other nearby code blocks (that were just a variable or member access) didn't have them.

Add information about finding a collection in `site.collections`
Information taken from the "Upgrading from 2.x to 3.x" page.
@ashmaroli

This comment has been minimized.

Show comment
Hide comment

@jekyllbot jekyllbot self-assigned this Jun 21, 2017

@DirtyF DirtyF assigned DirtyF and unassigned jekyllbot Jun 21, 2017

@DirtyF

This comment has been minimized.

Show comment
Hide comment
@DirtyF

DirtyF Jun 21, 2017

Member

Thanks for the reminder!

@jekyllbot: merge +docs

Member

DirtyF commented Jun 21, 2017

Thanks for the reminder!

@jekyllbot: merge +docs

@jekyllbot jekyllbot merged commit 285fe73 into jekyll:master Jun 21, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

jekyllbot added a commit that referenced this pull request Jun 21, 2017

@annegentle

This comment has been minimized.

Show comment
Hide comment
@annegentle

annegentle Jun 24, 2017

Contributor

I can see this addition in the source file, but the example within the <code> tags doesn't render properly. Here's a side-by-side screenshot on Chrome Mac OS X.

screen shot 2017-06-24 at 3 59 01 pm

Contributor

annegentle commented Jun 24, 2017

I can see this addition in the source file, but the example within the <code> tags doesn't render properly. Here's a side-by-side screenshot on Chrome Mac OS X.

screen shot 2017-06-24 at 3 59 01 pm

@ashmaroli

This comment has been minimized.

Show comment
Hide comment
@ashmaroli

ashmaroli Jun 25, 2017

Member

but the example within the <code> tags doesn't render properly.

Ah yes, my apologies @annegentle and @adamvoss I should've given a proper suggestion. The line should've actually been:

- <code>site.collections | where: "label", "myCollection" | first</code>
+ <code>{% raw %}{{ site.collections | where: "label", "myCollection" | first }}{% endraw %}</code>

it didn't render on site because Liquid parsed the code above and returned a falsy. The raw tags tell Liquid to ignore this code.

Member

ashmaroli commented Jun 25, 2017

but the example within the <code> tags doesn't render properly.

Ah yes, my apologies @annegentle and @adamvoss I should've given a proper suggestion. The line should've actually been:

- <code>site.collections | where: "label", "myCollection" | first</code>
+ <code>{% raw %}{{ site.collections | where: "label", "myCollection" | first }}{% endraw %}</code>

it didn't render on site because Liquid parsed the code above and returned a falsy. The raw tags tell Liquid to ignore this code.

@adamvoss

This comment has been minimized.

Show comment
Hide comment
@adamvoss

adamvoss Jun 25, 2017

Contributor

@ashmaroli I probably should have realized that switching it to full Liquid tags would need to be escaped.

I just made the change locally, and seeing it rendered, I am wondering again about whether the code block should be in braces.

image

Putting it in braces, to me, suggests usage advice. However, outputting the collection is not probably the typical usage. I suspect it more likely that it is be used with assign, so then I wonder if it should be:

{% assign myCollection = site.collections | where: "label", "myCollection" | first %}

Where if it is a fragment, not in braces, it is up to the user to decide how they want to use it.

Contributor

adamvoss commented Jun 25, 2017

@ashmaroli I probably should have realized that switching it to full Liquid tags would need to be escaped.

I just made the change locally, and seeing it rendered, I am wondering again about whether the code block should be in braces.

image

Putting it in braces, to me, suggests usage advice. However, outputting the collection is not probably the typical usage. I suspect it more likely that it is be used with assign, so then I wonder if it should be:

{% assign myCollection = site.collections | where: "label", "myCollection" | first %}

Where if it is a fragment, not in braces, it is up to the user to decide how they want to use it.

@pathawks

This comment has been minimized.

Show comment
Hide comment
@pathawks

pathawks Jun 25, 2017

Member

Looks like a new PR/issue needs to be opened for this.

Member

pathawks commented Jun 25, 2017

Looks like a new PR/issue needs to be opened for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment