summaryrefslogtreecommitdiff
path: root/main_test.go
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-07-13 11:38:42 -0600
committert <t@tjp.lol>2026-07-31 16:18:12 -0600
commit9f4971c92628052b8c51342b83b9aef966a4c318 (patch)
tree8d237adecde8ddbc421e09697977205743118ae3 /main_test.go
parent7711dcbfe619b616f2d78acbd524d289066576c1 (diff)
Plan fenced-code highlighting and add path template helpers
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go14
1 files changed, 14 insertions, 0 deletions
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())