Quote:
Originally Posted by eschwartz
Invoking templates inside GPM is ugly (and slower)  why not use this?
Code:
program:
# Initialize repetitive and/or complicated values for later use.
path = re(
field('#path'),
'\.',
'/'
);
seriesid = re(
field('#seriesid'),
'\.',
'/'
);
titleid = re(
field('#titleid'),
'\.',
'/'
);
sidx = finish_formatting(
field('series_index'),
'0>3s',
'',
'_'
);
subsidx = finish_formatting(
field('#subseries_index'),
'0>3s',
'',
'_'
);
# Compute final return value.
switch(
current_library_name(),
'Library - Main',
strcat(
path, '/', sidx, field('#subseries'), subsidx, field('title')
),
'Library - Special',
strcat(
path, '/', sidx, field('title')
),
'Library - In Progress',
strcat(
field('author_sort'), '/', field('series'), '/', sidx, field('title')
),
strcat(
path, '/', seriesid, titleid
)
)
|
You're right; that does look a lot cleaner, especially since I tend to use similar custom fields in all my libraries, so setting those values outside the main code block makes sense.
I'll have to give this a try.