Conditional Template Syntax: if TAG1 is missing, than use TAG2 instead #87

Closed
opened 2026-06-14 06:27:11 +00:00 by Sebastian_Berlin · 2 comments
Sebastian_Berlin commented 2026-06-14 06:27:11 +00:00 (Migrated from codeberg.org)

In some cases media sites are skipping the <description> tag (e. g. for breaking news) and the value in that (existing) tag is empty. Sometimes, but not regularly.

So in that condition, it would be good to have an addition to the implemented Conditional Template Syntax to avoid an empty teasing in the Mastodon post.

Example: If an item has an empty tag1 (for example <description>) than use tag2 (for example title) instead. Something like: {tag1|tag2}

In some cases media sites are skipping the `<description>` tag (e. g. for _breaking news_) and the value in that (existing) tag is empty. Sometimes, **but not** regularly. So in that condition, it would be good to have an addition to the implemented [Conditional Template Syntax](https://marvinsmastodontools.codeberg.page/feed2fedi/3.8.0/Config-File-Explained/#variables-starting-with-bot_) to avoid an empty teasing in the Mastodon post. Example: If an item has an empty _tag1_ (for example `<description>`) than use _tag2_ (for example `title`) instead. Something like: `{tag1|tag2}`
marvin8 commented 2026-06-16 23:31:09 +00:00 (Migrated from codeberg.org)

Thanks for the suggestion — this is a good use case, and it highlights a broader pattern: the template system has been growing one feature at a time (conditional prefix/suffix in #69, fallback here), and we're essentially building a template language piecemeal.

Rather than add the {var1|var2} syntax, I've opened #88 to migrate the template engine to Jinja2. That would make this a one-liner — {{ description | default(title) }} — and unlock everything else users might need (truncation, chaining, conditionals) without further custom parser work.

This issue will be the first concrete use case validated once #88 lands. Closing in favour of #88

Thanks for the suggestion — this is a good use case, and it highlights a broader pattern: the template system has been growing one feature at a time (conditional prefix/suffix in #69, fallback here), and we're essentially building a template language piecemeal. Rather than add the `{var1|var2}` syntax, I've opened #88 to migrate the template engine to Jinja2. That would make this a one-liner — `{{ description | default(title) }}` — and unlock everything else users might need (truncation, chaining, conditionals) without further custom parser work. This issue will be the first concrete use case validated once #88 lands. Closing in favour of #88
marvin8 commented 2026-06-19 06:25:50 +00:00 (Migrated from codeberg.org)

Addressed as part of version 4.0.0... which is a breaking change! The config file has subtley changed, however there is a migration helper included (feed2fedi-migrate-templates)

Addressed as part of version 4.0.0... which is a breaking change! The config file has subtley changed, however there is a migration helper included (`feed2fedi-migrate-templates`)
Sign in to join this conversation.
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
marvin8/feed2fedi#87
No description provided.