pg_render

pg_render

pg_render : Render HTML in SQL

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4290
pg_render
pg_render
0.1.3
UTIL
MIT
Rust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
See Also
pg_html5_email_address
pg_readme
gzip
bzip
zstd
http
pg_net
pg_curl

manual updated pgrx by Vonng

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
0.1.3
18
17
16
15
14
pg_render-
RPM
PIGSTY
0.1.3
18
17
16
15
14
pg_render_$v-
DEB
PIGSTY
0.1.3
18
17
16
15
14
postgresql-$v-pg-render-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
el8.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
el9.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
el9.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
el10.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
el10.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
d12.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
d12.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
d13.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
d13.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
u22.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
u22.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
u24.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
u24.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PackageVersionOSORGSIZEFile URL
pg_render_180.1.3el8.x86_64pigsty1.1 MiBpg_render_18-0.1.3-1PIGSTY.el8.x86_64.rpm
pg_render_180.1.3el8.aarch64pigsty906.8 KiBpg_render_18-0.1.3-1PIGSTY.el8.aarch64.rpm
pg_render_180.1.3el9.x86_64pigsty1.1 MiBpg_render_18-0.1.3-1PIGSTY.el9.x86_64.rpm
pg_render_180.1.3el9.aarch64pigsty970.5 KiBpg_render_18-0.1.3-1PIGSTY.el9.aarch64.rpm
pg_render_180.1.3el10.x86_64pigsty1.1 MiBpg_render_18-0.1.3-1PIGSTY.el10.x86_64.rpm
pg_render_180.1.3el10.aarch64pigsty988.4 KiBpg_render_18-0.1.3-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-render0.1.3d12.x86_64pigsty903.5 KiBpostgresql-18-pg-render_0.1.3-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-render0.1.3d12.aarch64pigsty709.4 KiBpostgresql-18-pg-render_0.1.3-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-render0.1.3d13.x86_64pigsty903.6 KiBpostgresql-18-pg-render_0.1.3-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-render0.1.3d13.aarch64pigsty709.1 KiBpostgresql-18-pg-render_0.1.3-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-render0.1.3u22.x86_64pigsty1014.7 KiBpostgresql-18-pg-render_0.1.3-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-render0.1.3u22.aarch64pigsty847.6 KiBpostgresql-18-pg-render_0.1.3-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-render0.1.3u24.x86_64pigsty1013.0 KiBpostgresql-18-pg-render_0.1.3-1PIGSTY~noble_amd64.deb
postgresql-18-pg-render0.1.3u24.aarch64pigsty841.3 KiBpostgresql-18-pg-render_0.1.3-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_render_170.1.3el8.x86_64pigsty1.1 MiBpg_render_17-0.1.3-1PIGSTY.el8.x86_64.rpm
pg_render_170.1.3el8.aarch64pigsty907.6 KiBpg_render_17-0.1.3-1PIGSTY.el8.aarch64.rpm
pg_render_170.1.3el9.x86_64pigsty1.1 MiBpg_render_17-0.1.3-1PIGSTY.el9.x86_64.rpm
pg_render_170.1.3el9.aarch64pigsty975.5 KiBpg_render_17-0.1.3-1PIGSTY.el9.aarch64.rpm
pg_render_170.1.3el10.x86_64pigsty1.1 MiBpg_render_17-0.1.3-1PIGSTY.el10.x86_64.rpm
pg_render_170.1.3el10.aarch64pigsty988.6 KiBpg_render_17-0.1.3-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-render0.1.3d12.x86_64pigsty905.2 KiBpostgresql-17-pg-render_0.1.3-1PIGSTY~bookworm_amd64.deb
postgresql-17-pg-render0.1.3d12.aarch64pigsty709.5 KiBpostgresql-17-pg-render_0.1.3-1PIGSTY~bookworm_arm64.deb
postgresql-17-pg-render0.1.3d13.x86_64pigsty903.5 KiBpostgresql-17-pg-render_0.1.3-1PIGSTY~trixie_amd64.deb
postgresql-17-pg-render0.1.3d13.aarch64pigsty710.1 KiBpostgresql-17-pg-render_0.1.3-1PIGSTY~trixie_arm64.deb
postgresql-17-pg-render0.1.3u22.x86_64pigsty1011.1 KiBpostgresql-17-pg-render_0.1.3-1PIGSTY~jammy_amd64.deb
postgresql-17-pg-render0.1.3u22.aarch64pigsty847.4 KiBpostgresql-17-pg-render_0.1.3-1PIGSTY~jammy_arm64.deb
postgresql-17-pg-render0.1.3u24.x86_64pigsty1012.6 KiBpostgresql-17-pg-render_0.1.3-1PIGSTY~noble_amd64.deb
postgresql-17-pg-render0.1.3u24.aarch64pigsty839.6 KiBpostgresql-17-pg-render_0.1.3-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_render_160.1.3el8.x86_64pigsty1.1 MiBpg_render_16-0.1.3-1PIGSTY.el8.x86_64.rpm
pg_render_160.1.3el8.aarch64pigsty907.6 KiBpg_render_16-0.1.3-1PIGSTY.el8.aarch64.rpm
pg_render_160.1.3el9.x86_64pigsty1.1 MiBpg_render_16-0.1.3-1PIGSTY.el9.x86_64.rpm
pg_render_160.1.3el9.aarch64pigsty970.7 KiBpg_render_16-0.1.3-1PIGSTY.el9.aarch64.rpm
pg_render_160.1.3el10.x86_64pigsty1.1 MiBpg_render_16-0.1.3-1PIGSTY.el10.x86_64.rpm
pg_render_160.1.3el10.aarch64pigsty988.5 KiBpg_render_16-0.1.3-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-render0.1.3d12.x86_64pigsty902.8 KiBpostgresql-16-pg-render_0.1.3-1PIGSTY~bookworm_amd64.deb
postgresql-16-pg-render0.1.3d12.aarch64pigsty709.5 KiBpostgresql-16-pg-render_0.1.3-1PIGSTY~bookworm_arm64.deb
postgresql-16-pg-render0.1.3d13.x86_64pigsty904.5 KiBpostgresql-16-pg-render_0.1.3-1PIGSTY~trixie_amd64.deb
postgresql-16-pg-render0.1.3d13.aarch64pigsty710.1 KiBpostgresql-16-pg-render_0.1.3-1PIGSTY~trixie_arm64.deb
postgresql-16-pg-render0.1.3u22.x86_64pigsty1011.2 KiBpostgresql-16-pg-render_0.1.3-1PIGSTY~jammy_amd64.deb
postgresql-16-pg-render0.1.3u22.aarch64pigsty847.5 KiBpostgresql-16-pg-render_0.1.3-1PIGSTY~jammy_arm64.deb
postgresql-16-pg-render0.1.3u24.x86_64pigsty1012.8 KiBpostgresql-16-pg-render_0.1.3-1PIGSTY~noble_amd64.deb
postgresql-16-pg-render0.1.3u24.aarch64pigsty839.5 KiBpostgresql-16-pg-render_0.1.3-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_render_150.1.3el8.x86_64pigsty1.1 MiBpg_render_15-0.1.3-1PIGSTY.el8.x86_64.rpm
pg_render_150.1.3el8.aarch64pigsty907.9 KiBpg_render_15-0.1.3-1PIGSTY.el8.aarch64.rpm
pg_render_150.1.3el9.x86_64pigsty1.1 MiBpg_render_15-0.1.3-1PIGSTY.el9.x86_64.rpm
pg_render_150.1.3el9.aarch64pigsty971.1 KiBpg_render_15-0.1.3-1PIGSTY.el9.aarch64.rpm
pg_render_150.1.3el10.x86_64pigsty1.1 MiBpg_render_15-0.1.3-1PIGSTY.el10.x86_64.rpm
pg_render_150.1.3el10.aarch64pigsty988.7 KiBpg_render_15-0.1.3-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-render0.1.3d12.x86_64pigsty904.6 KiBpostgresql-15-pg-render_0.1.3-1PIGSTY~bookworm_amd64.deb
postgresql-15-pg-render0.1.3d12.aarch64pigsty709.8 KiBpostgresql-15-pg-render_0.1.3-1PIGSTY~bookworm_arm64.deb
postgresql-15-pg-render0.1.3d13.x86_64pigsty903.8 KiBpostgresql-15-pg-render_0.1.3-1PIGSTY~trixie_amd64.deb
postgresql-15-pg-render0.1.3d13.aarch64pigsty709.7 KiBpostgresql-15-pg-render_0.1.3-1PIGSTY~trixie_arm64.deb
postgresql-15-pg-render0.1.3u22.x86_64pigsty1015.3 KiBpostgresql-15-pg-render_0.1.3-1PIGSTY~jammy_amd64.deb
postgresql-15-pg-render0.1.3u22.aarch64pigsty847.7 KiBpostgresql-15-pg-render_0.1.3-1PIGSTY~jammy_arm64.deb
postgresql-15-pg-render0.1.3u24.x86_64pigsty1012.3 KiBpostgresql-15-pg-render_0.1.3-1PIGSTY~noble_amd64.deb
postgresql-15-pg-render0.1.3u24.aarch64pigsty841.4 KiBpostgresql-15-pg-render_0.1.3-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_render_140.1.3el8.x86_64pigsty1.1 MiBpg_render_14-0.1.3-1PIGSTY.el8.x86_64.rpm
pg_render_140.1.3el8.aarch64pigsty907.0 KiBpg_render_14-0.1.3-1PIGSTY.el8.aarch64.rpm
pg_render_140.1.3el9.x86_64pigsty1.1 MiBpg_render_14-0.1.3-1PIGSTY.el9.x86_64.rpm
pg_render_140.1.3el9.aarch64pigsty970.9 KiBpg_render_14-0.1.3-1PIGSTY.el9.aarch64.rpm
pg_render_140.1.3el10.x86_64pigsty1.1 MiBpg_render_14-0.1.3-1PIGSTY.el10.x86_64.rpm
pg_render_140.1.3el10.aarch64pigsty988.7 KiBpg_render_14-0.1.3-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-render0.1.3d12.x86_64pigsty903.8 KiBpostgresql-14-pg-render_0.1.3-1PIGSTY~bookworm_amd64.deb
postgresql-14-pg-render0.1.3d12.aarch64pigsty709.9 KiBpostgresql-14-pg-render_0.1.3-1PIGSTY~bookworm_arm64.deb
postgresql-14-pg-render0.1.3d13.x86_64pigsty903.8 KiBpostgresql-14-pg-render_0.1.3-1PIGSTY~trixie_amd64.deb
postgresql-14-pg-render0.1.3d13.aarch64pigsty709.5 KiBpostgresql-14-pg-render_0.1.3-1PIGSTY~trixie_arm64.deb
postgresql-14-pg-render0.1.3u22.x86_64pigsty1014.3 KiBpostgresql-14-pg-render_0.1.3-1PIGSTY~jammy_amd64.deb
postgresql-14-pg-render0.1.3u22.aarch64pigsty847.6 KiBpostgresql-14-pg-render_0.1.3-1PIGSTY~jammy_arm64.deb
postgresql-14-pg-render0.1.3u24.x86_64pigsty1009.6 KiBpostgresql-14-pg-render_0.1.3-1PIGSTY~noble_amd64.deb
postgresql-14-pg-render0.1.3u24.aarch64pigsty841.6 KiBpostgresql-14-pg-render_0.1.3-1PIGSTY~noble_arm64.deb

Source

pig build pkg pg_render;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_render;		# install via package name, for the active PG version

pig install pg_render -v 18;   # install for PG 18
pig install pg_render -v 17;   # install for PG 17
pig install pg_render -v 16;   # install for PG 16
pig install pg_render -v 15;   # install for PG 15
pig install pg_render -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pg_render;

Usage

pg_render: Liquid template rendering for PostgreSQL

render(template text, input json|array|value)

Render a template with query results using Liquid syntax:

-- Single value
SELECT render('Total: {{ value }}', (SELECT count(*) FROM posts));

-- Multiple columns from one row
SELECT render(
    '<h1>{{ title }}</h1><p>{{ text }}</p>',
    (SELECT to_json(r) FROM (SELECT title, text FROM posts WHERE id = 1) r)
);

-- Loop over an array
SELECT render(
    '{% for v in values %} {{ v }} {% endfor %}',
    (SELECT array(SELECT title FROM posts))
);

-- Loop over multiple rows with multiple columns
SELECT render(
    '{% for row in rows %} {{ row.title }} - {{ row.author }} {% endfor %}',
    json_agg(to_json(posts.*))
) FROM posts;

render_agg(template text, input record|json|value)

Aggregate render function – renders a template for each row:

-- Render each row from a derived table
SELECT render_agg('{{ title }} {{ text }}', props)
FROM (SELECT title, text FROM posts) AS props;

-- Render using json_build_object
SELECT render_agg(
    '<article><h1>{{ title }}</h1></article>',
    json_build_object('title', title)
) FROM posts;

Using Stored Templates

SELECT render(
    (SELECT template FROM templates WHERE id = 'my_tpl'),
    (SELECT to_json(r) FROM (SELECT title, text FROM posts WHERE id = 1) r)
);

PostgREST Integration

CREATE FUNCTION api.index() RETURNS "text/html" AS $$
SELECT render(
    '<html><body><h1>{{ title }}</h1></body></html>',
    (SELECT to_json(r) FROM (SELECT title FROM posts WHERE id = 1) r)
) $$;
Last updated on