View Single Post
Old 12-06-2023, 01:03 AM   #8
kjdavies
Zealot
kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.
 
Posts: 112
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
Quote:
Originally Posted by chaley View Post
This avoids any extraneous periods by including a preceeding dot only if the column has a value:
Code:
{#titlecount:}{#pagecount:|.|}{series:|.|}{#pubseries:|.|}{#pubseries_index|.|}
However, I prefer this GPM template that (I think) makes the intentions explicit.
Code:
program:
	list_join('.', $#titlecount, '.', $#pagecount, '.', $series, '.',$#pubseries, '.', $#pubseries_index, '.')
The above can be written as a TPM template if it is embedded with other template expressions:
Code:
{:'list_join('.', $#titlecount, '.', $#pagecount, '.', $series, '.',$#pubseries, '.', $#pubseries_index, '.')'}
How about

Code:
program:
    '.'.join(filter(None, ($#titlecount,$#pagecount,$series,$#pubseries,$#pubseries_index)))
? I think this should make a string concatenating only the non-None values in the list, and prevent leading or trailing '.'.
kjdavies is offline   Reply With Quote