Added function filter_by to grains module

This will help to keep too much conditional logic out of Jinja templates
by allowing the creation of unobtrusive lookup tables.