Quote:
Originally Posted by ownedbycats
I was having trouble with the regex and basically just put in the first thing that actually halfway worked.
Oddly, template tester isn't removing the url: identifier either:
Attachment 191593
If I take out the check for 'standard', it works:
Attachment 191595
Is it looking at the state of the column at the beginning of the template, when it only has the url identifier? That would explain why it works running it a second time.
|
It is looking at the value of "s", which is the result of the select() on line 5. It doesn't see any changes you make to "ids" after line 5.
However, I suspect your logic won't do what you want. If s is non-empty then there is a "standard" identifier. If s != u then you add a standard identifier, which is probably different from the original so there are now 2 of them in the list. When you save the identifiers calibre will pick one of them; which one is undefined. Thus if s is non-empty then you must remove the existing "standard" identifier before adding a different "standard" identifer.
Once you have done the above the rest of your logic assumes that 's' contains the current value of the "standard" identifier. Your template must ensure that is the case, perhaps by assigning to 's'.
Depending on what you are doing it might be easier and less buggy to loop through the identifiers, building a new identifiers list.