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.
Merge pull request #6586 from whiteinge/grains-filter_by

Added function filter_by to grains module