Templating

  • Updated 2 days ago by leah

The Caddy webserver that we use lets you use templating syntax so you can write dynamic pages that use data from the server to do "interesting things"

How this bullshit works

The main way to provide dynamic content on your WWWAS site is by using JavaScript, but there's many occasions where such use would be inappropriate. A lot of the time, you can use server-side templates instead

Basically, when someone visits your page, the web server looks for fancy bits of text surrounded with {{ and }} and then turns them into something else.

Here's a little example:

Today's date is {{now | date "2006-01-02"}}

which becometh:

Today's date is 2026-10-14

Let's break this example down. now is a function that gives you the current date. The date function takes two arguments, and formats that date into a human-readable format based on the template we give it in the first argument. The | feeds the value returned by now into the last (i.e., second) argument of date.