Cleaning up template generation

Changes:
- Added utility functions for displaying nodes conditionally
- Cleaned up template generators; when and when-not instead of if with nil