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

How are collections made available in templates #6

Closed
keerts opened this issue Mar 21, 2014 · 7 comments
Closed

How are collections made available in templates #6

keerts opened this issue Mar 21, 2014 · 7 comments

Comments

@keerts
Copy link

keerts commented Mar 21, 2014

How are collections made available in templates, for example jade?

@keerts
Copy link
Author

keerts commented Mar 22, 2014

Found out they are available under their very own name:

for col in collections.overview
  li= col.title
else
  ...

The reason I didn't find this at first, is that the collections plugin must be the first to run, not the last. Very obvious actually.

@ianstormtaylor
Copy link
Contributor

ah yup, sorry for the confusion there. they just need to be before your templating step if you want to use em in the templates

@ianstormtaylor
Copy link
Contributor

the globals exposed are a single collections dictionary of all of the collections arrays, and then a COLLECTION global for each of the collection keys, for example articles or guides that is an array of the files

i've been debating whether to simplify to just a single collections dictionary global

@keerts
Copy link
Author

keerts commented Apr 9, 2014

I would vote in favor of just the collections global

On Mon, Mar 31, 2014 at 7:40 PM, Ian Storm Taylor
notifications@github.comwrote:

the globals exposed are a single collections dictionary of all of the
collections arrays, and then a COLLECTION global for each of the
collection keys, for example articles or guides that is an array of the
files

i've been debating whether to simplify to just a single collectionsdictionary global

Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-39117860
.

@daGrevis
Copy link

daGrevis commented May 3, 2014

they just need to be before your templating step if you want to use em in the templates

That's an important point. I suggest to add that to README.md.

@jmatsushita
Copy link

+1 to add to the README.md in fact I think this would be a great documentation structure to suggest for all plugins given the pipeline nature of metalsmith. Maybe something like a "Template Usage" section or maybe - since we're not necessarily using the template plugin - "Using the results" or "Results"? Would help get a sense of what each plugin achieves, which for now is usually only minimally described in intros.

@mokagio
Copy link

mokagio commented Jun 18, 2014

+1 to add to the README, I understand that it's fairly obvious and logical to that if you need a variable in a template it needs to be defined before the template, but it's still not an immediate thing to notice, specially if you are a beginner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants