me: this HTML generation code is awful

me: *heavily refactors the code*

me: this HTML generation code might be even worse

imagine getting annoyed enough by your own code that you just reinvent s-expurressions but with extra steps so you can finally work with an API you can tolerate

Follow

long, code 

const htmlText = html(
{ lang: "en-X-catspeak" },
head(
title("*stares at you*"),
meta({ charset: "utf-8" }),
meta({
content: "width=device-width, initial-scale=1.0",
name: "viewport",
}),
link({ href: "/style.css", rel: "stylesheet" }),
),
body(
article(
header(h1(a({ href: "/" }, "example.org"))),
main(
h1("*stares at you*"),
img({
src: "/img/whatever",
alt: "whatever",
title: "whatever",
}),
dl(
dt("description"),
dd("whatever"),
dt("artist"),
dd(a({ href: "https://example.org/" }, "kame_3")),
dt("source link"),
dd(
a({ href: "https://example.org/" }, "https://example.org/"),
" ",
a({ href: "https://example.org/" }, "[archived]"),
),
),
nav(
{ class: "controls" },
a({ href: "https://example.org/", class: "button" }, "next"),
a({ href: "/", class: "button" }, "back to gallery"),
),
),
),
),
);

oh boy i can’t wait to refactor my codebase fur the second time in the same day

my original idea was some fun and kinda elegant template tag nonsense. but it doesn’t purretty purrint well at all and all the quoting is nasty

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.