Conditional Template Syntax: if TAG1 is missing, than use TAG2 instead #87
Labels
No labels
bug
contribution welcome
duplicate
enhancement
good first issue
help wanted
invalid
question
upstream
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Reference
marvin8/feed2fedi#87
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 exampletitle) instead. Something like:{tag1|tag2}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
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)