docs: fix missing -> in <has series#-> example

The conditional open tag requires the -> delimiter. Written as
<has series#>, the engine does not recognize a conditional, so the
later <-has> closes the enclosing <if series-> instead and the template
reports "Missing <-if series> closing conditional." while leaking the
literal text "<has series#>" into the name.

Also add a nested-conditional example, since the reference table only
shows each conditional in isolation, plus regression tests for
<has series#-> nested inside <if series-> when a book is in a series
but has no series number.

Co-authored-by: rmcrackan <rmcrackan@gmail.com>
This commit is contained in:
Cursor Agentandrmcrackan committed 2026-08-12 04:11:39 +00:00
1 parent 895e47d513
commit f36e302c93
2 files changed
+31 -1

No files matched your search

@@ -782,6 +782,32 @@ namespace TemplatesTests
.Should().Be(expected);
}
[TestMethod]
// a book can be in a series but have no series number. <has series#-> nested inside
// <if series-> is the way to keep the number's punctuation out of the name in that case.
[DataRow("<if series-><first series>|<has series#-><series#>. <-has><-if series><title short>", "1", "Series A|1. A Study in Scarlet")]
[DataRow("<if series-><first series>|<has series#-><series#>. <-has><-if series><title short>", "", "Series A|A Study in Scarlet")]
[DataRow("<if series-><first series>|<has series#-><series#>. <-has><-if series><title short>", null, "A Study in Scarlet")]
// without the conditional, a missing number leaves its trailing punctuation behind
[DataRow("<if series-><first series>|<series#>. <-if series><title short>", "", "Series A|. A Study in Scarlet")]
// and a missing number between two spaces leaves a double space, which is then collapsed
[DataRow("<if series-><first series><has series#-> <series#><-has> - <-if series><title short>", "1", "Series A 1 - A Study in Scarlet")]
[DataRow("<if series-><first series><has series#-> <series#><-has> - <-if series><title short>", "", "Series A - A Study in Scarlet")]
[DataRow("<if series-><first series[{N}{ {#}}]> - <-if series><title short>", "1", "Series A 1 - A Study in Scarlet")]
[DataRow("<if series-><first series[{N}{ {#}}]> - <-if series><title short>", "", "Series A - A Study in Scarlet")]
public void HasSeriesNumber_nested_in_IfSeries(string template, string? seriesOrder, string expected)
{
var bookDto = GetLibraryBook(seriesOrder is null ? null : [new SeriesDto("Series A", seriesOrder, "B1")]);
Templates.TryGetTemplate<Templates.FileTemplate>(template, out var fileTemplate).Should().BeTrue();
fileTemplate.Errors.Should().HaveCount(0);
fileTemplate.Warnings.Should().HaveCount(0);
fileTemplate
.GetFilename(bookDto, "", "", culture: CultureInfo.InvariantCulture, replacements: Replacements)
.PathWithoutPrefix
.Should().Be(expected);
}
[TestMethod]
[DataRow(@"C:\a\b", @"C:\a\b\foobar.ext", PlatformID.Win32NT)]
[DataRow(@"/a/b", @"/a/b/foobar.ext", PlatformID.Unix)]
+5 -1
View File
@@ -102,7 +102,11 @@ As an example, this folder template will place all Liberated podcasts into a "Po
This example will add a number if the `<series#>` tag has a value:
`<has series#><series#><-has>`
`<has series#-><series#><-has>`
Conditionals may be nested. This folder template puts every book under its series, and prefixes the book folder with the series number only for the books that have one, so that books without a number don't end up in a folder starting with `.`:
`<if series-><first series>/<has series#-><series#>. <-has><-if series><title short>`
This example will put non-series books in a "Standalones" folder: