From 9f4971c92628052b8c51342b83b9aef966a4c318 Mon Sep 17 00:00:00 2001 From: t Date: Mon, 13 Jul 2026 11:38:42 -0600 Subject: Plan fenced-code highlighting and add path template helpers --- main_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'main_test.go') diff --git a/main_test.go b/main_test.go index a1eda14..66d793f 100644 --- a/main_test.go +++ b/main_test.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "encoding/xml" + "html/template" "os" "path/filepath" "strings" @@ -371,6 +372,19 @@ func TestSortingFilteringSlicing(t *testing.T) { } } +func TestPathTemplateFunctions(t *testing.T) { + tmpl := template.Must(template.New("path").Funcs(templateFuncs()).Parse( + `{{$parts := splitPath "notes/sync/recipes/soup.md"}}{{dirPath (joinPath (slice $parts 2))}}|{{dirPath "soup.md"}}`, + )) + var output strings.Builder + if err := tmpl.Execute(&output, nil); err != nil { + t.Fatal(err) + } + if got := output.String(); got != "recipes|" { + t.Fatalf("path = %q, want recipes|", got) + } +} + func TestUnchangedOutputsKeepMtime(t *testing.T) { root := t.TempDir() writeTestFile(t, root, "layout.tmpl", testLayouts()) -- cgit v1.3