What are some best practices for handling conditional logic in templates while maintaining separation of concerns?

When handling conditional logic in templates while maintaining separation of concerns, it is important to keep the business logic separate from the presentation logic. One way to achieve this is by using a template engine like Twig, which allows for the use of conditional statements within templates without mixing them with PHP logic. By keeping the conditional logic within the template files, it becomes easier to maintain and update the presentation layer without affecting the underlying business logic.

// Template file using Twig syntax
{% if user.isAdmin %}
    <p>Welcome Admin!</p>
{% else %}
    <p>Welcome User!</p>
{% endif %}