TheLocehiliosan / yadm

Yet Another Dotfiles Manager

Home Page:https://yadm.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Templates with a matching alternate condition are not used

cmvanb opened this issue · comments

commented

Describe the bug

A template with an alternate condition that should be matched is not used.

To reproduce

Steps to reproduce the behavior:

  1. yadm init
  2. yadm config local.class example
  3. echo "aaa" > file.txt##template
  4. yadm add file.txt##template
  5. echo "bbb" > file.txt##class.example,template
  6. yadm add file.txt##class.example,template
  7. yadm alt

Expected behavior

I expected the following:

Creating file.txt from template file.txt##class.example,template

Instead this happens:

Creating file.txt from template file.txt##template

Environment

  • Operating system: Arch Linux 6.3.5
  • Version yadm: 3.2.2
  • Version Git: 2.40.1

Additional context

I was able to reproduce this with the docker image:
script.gz

Files are actually a special kind of alternate. (only one file is ever considered for templates that target a particular path, and it is based on the ordering of the file names, the last one found)

Instead of attempting to combine the example identifiers in the filename, the template should be created like this:

{% if yadm.class == "example" %}
This block is included for class example
{% else %}
This block is included if the class is not example
{% endif %}

Can you merge the content into a single template for the file which has different sections based on class?

Thank you for your reply. Yes I did eventually come to that solution.

I would have preferred to use separate files (it feels more cleanly separated), but the class conditional works as needed.

It wasn't clear to me from the documentation that templates and alternates cannot be combined.

Shall I close this issue?

This issue has been labeled as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

This issue was closed because it has been labeled as stale for 7 days with no activity.