Skip to content

Instantly share code, notes, and snippets.

@kylerush
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save kylerush/9612647 to your computer and use it in GitHub Desktop.

Select an option

Save kylerush/9612647 to your computer and use it in GitHub Desktop.
dist/
blog/
post1.html
post2.html
post3.html
index.html
src/
content/
blog/
post1.hbs
post2.hbs
post3.hbs
templates/
default.hbs
post.hbs
pages/
index.hbs
about.hbs
@kylerush
Copy link
Copy Markdown
Author

I need a for loop in src/pages/index.hbs that iterates through all the files (blog posts) in src/content/blog and outputs to dist/index.html. How do I do this in the Gruntfile?

@jonschlinkert
Copy link
Copy Markdown

No problem, let me put an example together.

@jonschlinkert
Copy link
Copy Markdown

@kylerush, if you have any questions about how I'm doing thing in the example project, feel free to ping me.

I'm using a custom {{resolve}} helper to calculate urls for links, it's great for the current setup because it automatically figures everything out, but it won't work with multiple targets because of limitations with grunt. There are other solutions that are more bullet proof but require more code in the examples.

Hope this helps!

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