jgonyea / grav-plugin-podcast

GravCMS plugin that creates podcast channel and podcast episode page templates along with a podcast RSS feed.
MIT License
18 stars 7 forks source link

Code simplification for datestamp fallback #51

Closed aleclerc7 closed 2 years ago

aleclerc7 commented 2 years ago

Hello,

partials/podcast_episodes_list.html.twig lines 12-18:

            {% if (e.header.publish_date) %}
                {% set datestamp = e.header.publish_date %}
            {% elseif (e.header.date) %}
                {% set datestamp = e.header.date %}
            {% else %}
                {% set datestamp = e.modified %}
            {% endif %}

It can be written in one line: {% set datestamp = e.header.publish_date ?: e.header.date ?: e.modified %}

Kind regards.

jgonyea commented 2 years ago

Thanks. I'm aware of the ternary syntax, but I find the extra cognitive load to not be worth the lesser number of code lines.