Queries encapsulate complex logic and make templates more maintainable. Use them for calculations, boolean tests, and data transformations.
Well-designed queries abstract away implementation details, making templates read like domain-specific languages.