See http://stackoverflow.com/a/14381327/130638 for explanation.
DocPad: Querying custom categories (via single categories object)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
templateData: | |
categories: | |
a: | |
slug: 'a' | |
description: 'first letter of alphabet' | |
b: | |
slug: 'b' | |
description: 'second letter of alphabet' | |
getDocumentsForCategory: (categoryId) -> | |
return @getCollection('documents').findAll(categories: $has: categoryId) | |
getCategoriesForDocument: (document) -> | |
document ?= @getDocument() | |
categoryIds = document.get('categories') | |
categories = @categories[categoryId] for categoryId in categoryIds | |
return categories | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment