From 93670740c05def63ae4b02c99eb49391f663ff38 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 27 Dec 2025 06:44:59 -0500 Subject: Add initial version of ssg --- man/ssg-templates.5 | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 man/ssg-templates.5 (limited to 'man/ssg-templates.5') diff --git a/man/ssg-templates.5 b/man/ssg-templates.5 new file mode 100644 index 0000000..2f1dbd6 --- /dev/null +++ b/man/ssg-templates.5 @@ -0,0 +1,83 @@ +.TH SSG-TEMPLATES 5 "December 2025" "ssg" "File Formats" +.SH NAME +ssg-templates \- ssg template format +.SH DESCRIPTION +ssg templates use Go's +.B html/template +syntax. Each HTML file in the templates directory is processed and rendered +to the output directory with the same filename. +.SH DATA +Data from JSON files in the data directory is made available to templates. +Each file becomes a template variable named after the file (without the +.I .json +extension). +.PP +For example, if +.I data/projects.json +contains: +.PP +.RS +.nf +[ + {"name": "foo", "url": "https://example.com/foo", "featured": true}, + {"name": "bar", "url": "https://example.com/bar", "featured": false} +] +.fi +.RE +.PP +It can be accessed in templates as +.BR .projects : +.PP +.RS +.nf +{{range .projects}} +
  • {{.name}}
  • +{{end}} +.fi +.RE +.SH FUNCTIONS +.SS filter +The +.B filter +function returns items from an array where a field equals a value. +.PP +.RS +.nf +{{range filter .projects "featured" true}} +
  • {{.name}}
  • +{{end}} +.fi +.RE +.PP +This would output only "foo" since it has +.B featured +set to +.BR true . +.SH SYNTAX +Templates use Go's text/template syntax: +.TP +.B {{.field}} +Output a field value. +.TP +.B {{range .items}}...{{end}} +Iterate over a list. +.TP +.B {{if .condition}}...{{end}} +Conditional rendering. +.TP +.B {{with .object}}...{{end}} +Set dot to the object for the block. +.PP +See the Go +.B html/template +documentation for full syntax details. +.SH FILES +.TP +.I data/*.json +JSON data files. Each becomes a template variable. +.TP +.I templates/*.html +HTML templates to render. +.SH SEE ALSO +.BR ssg (1), +.BR ssg-build (1) -- cgit v1.2.3