View Single Post
Old 04-29-2023, 09:27 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,453
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Don't remember about specific tags in SFM. But this will list the first tag alphabetically and also get rid of an extra '-' when there's no tag.

{tags:sublist(0,1,&)| - |}
Quote:
Originally Posted by chrisric View Post
Thanks ownedbycats.

Using {tags:sublist(0,1,&)| - |} produces the same result as {tags}

I searched "Reference for all built-in template language function" and found nothing specific to tags that might work. Of course, I have no idea if any of the other functions may work.

I guess I could save the file with {tags} and use an external script to rename the file. I'd prefer that being a last resort though.
Read up on the list functions. They all work on tags.

The separator for tags is a comma, not an ampersand. As said in Using functions in templates - Single Function Mode (SFM), you enter a literal comma using \,
Code:
{tags:sublist(0,1,\,)}
The following template in Template Program Mode (TPM), is easier to understand (for me at least):
Code:
{tags:'sublist($, 0, 1, ',')'| - |}
However, you appear to be asking to test for the existence of a particular tag. That can be done by embedding General Program Mode (GPM) into TPM
Code:
{tags:'if '^xyz$' inlist $tags then 'xzy' fi'| - |}
If for some reason you don't want to embed GPM then this "pure" TPM template does it:
Code:
{tags:'in_list($, ',', '^xyz$', 'xyz', '')'| - |}
chaley is offline   Reply With Quote