For crossplatform and shared computer reasons, I would like to modify a zotero integration template so that it extracts an attachment's basename from attatchment.path. For example, I'd like a basename() macro that can be used like this:
{% for attachment in attachments | filterby("path", "endswith", ".pdf") %} | [[basename(attachment.path)|PDF]] {%- endfor %}
I tried to come up with such a macro, but only proved that I don't know nunjucks.
In e.g. python, this would be easy and robust to corner cases. Is there reliable way to do this in nunjucks?
For crossplatform and shared computer reasons, I would like to modify a zotero integration template so that it extracts an attachment's basename from
attatchment.path
. For example, I'd like abasename()
macro that can be used like this:{% for attachment in attachments | filterby("path", "endswith", ".pdf") %} | [[basename(attachment.path)|PDF]] {%- endfor %}
I tried to come up with such a macro, but only proved that I don't know nunjucks.
In e.g. python, this would be easy and robust to corner cases. Is there reliable way to do this in nunjucks?