plmustache
plmustache · Render Mustache templates as PostgreSQL functions using a trusted procedural language.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102306 | plmustache | plmustache | 0.1 | LANG | MIT | C |
PostgreSQL · 14, 15, 16, 17
Usage
Sources:
- README.md
- LICENSE
- Makefile
- plmustache.control.in
- sql/plmustache.sql
- src/plmustache.c
- .github/workflows/ci.yaml
plmustache renders Mustache templates through PostgreSQL functions. The current source Makefile generates control and installation SQL version 0.1; the historical release tag v0.1 instead contains SQL version 0.0.1. This page describes the pinned source snapshot, without claiming a supported upgrade between those versions. Its C library requires libmustach. Current CI covers PostgreSQL 14–17; the older README lists 12–16.
Render a Template
After the matching generated control, SQL and library files are installed, a superuser creates the extension. No shared preload or server restart is required for ordinary use:
The extension’s control does not mark installation trusted; the installed procedural language itself is TRUSTED. These are separate permission boundaries. Named function arguments provide template variables, with returned output as text. The library supplies call, inline and validation handlers, but the inline handler rejects DO blocks.
Escaping and Sections
Double braces escape HTML; triple braces return the raw value. For example:
Treat unescaped output as untrusted content at the rendering boundary. HTML escaping is not SQL quoting, JSON encoding or a general injection defense. The README demonstrates boolean sections and array iteration, while its roadmap is incomplete; verify exact argument types against the source tests. Partials, inheritance and lambdas are not established supported features in this snapshot.
Maintenance
Keep generated SQL/control versions and the installed C library aligned. Existing backends retain a loaded old library until they disconnect. The source layout and version have moved since the old release; review the installation and any migration in an isolated database instead of assuming the old v0.1 artifact installs the current SQL version.