News for hackers. Stuff that matters.
Re:Type-safe HTML templating in Zig by fergie on Monday October 12, 2026 @01:56AM (#50051874)
W3C: Why can't we just have <includes src="./header.html"> and be done with it?
Re:Type-safe HTML templating in Zig by pwdisswordfishq on Monday October 12, 2026 @03:46AM (#50052812)
Re:Type-safe HTML templating in Zig by fergie on Tuesday October 13, 2026 @03:36AM (#50068112)
Thats XSLT which is tragically being removed from browsers as we speak: https://developer.chrome.com/docs/web-platform/deprecating-x...

I say tragically, because XSLT was indeed the only sort-of workaround that was available for templating in the browser, even if it was limited to v1 rather than the much more useful v2 and v3.

Re:Type-safe HTML templating in Zig by tannhaeuser on Monday October 12, 2026 @03:04AM (#50052403)
SGML (ISO 8879), the markup meta-language on which HTML is based, has that, as well as many other things, such as type-checked templating.

Hence HTML as a mere vocabulary making use of SGML's facilities didn't need to define its own ad-hoc mechanism.

Btw the <?php ...> construct is also derived from SGML. In SGML terms it's a "processing instruction" rather than an "entity reference", the latter being the basic means for content inclusion.

Re:Type-safe HTML templating in Zig by fergie on Thursday October 15, 2026 @01:57AM (#50099762)
All of this is correct, but it still requires PHP on the server- this will not work in HTML itself.
Re:Type-safe HTML templating in Zig by pautasso on Monday October 12, 2026 @02:42AM (#50052209)
Nice idea!

https://web.dev/articles/imports

Been there, tried that.

Introduced in 2014 (Chrome 36) Deprecated 2018 (Chrome 70) Retired 2019 (Chrome 73)

Re:Type-safe HTML templating in Zig by fergie on Tuesday October 13, 2026 @03:43AM (#50068141)
Big fan of what you did there- baffling that it was beaten out by Webcomponents. I feel like <imports> should be brought back.
Re:Type-safe HTML templating in Zig by cton on Monday October 12, 2026 @02:24AM (#50052078)
Re:Type-safe HTML templating in Zig by fergie on Tuesday October 13, 2026 @03:40AM (#50068130)
Yes, partial refresh strategies are interesting, but its an adjacent problem.
Re:Type-safe HTML templating in Zig by jrimbault on Monday October 12, 2026 @02:11AM (#50051979)
<?php include "header.html" ?>
Re:Type-safe HTML templating in Zig by fergie on Monday October 12, 2026 @02:14AM (#50052010)
Yes, but then you need php

Why is there no direct support for templating in HTML itself?

Re:Type-safe HTML templating in Zig by alternatex on Monday October 12, 2026 @06:28AM (#50054271)
It's a markup language for documents. If you enable templating devs are then going to ask for more. Eventually it will end up turing complete. Such is the development arc of a lot of languages.
Re:Type-safe HTML templating in Zig by williamdclt on Monday October 12, 2026 @08:33AM (#50055503)
> If you enable templating devs are then going to ask for more

This might be the worst argument for anything I've read this week, there's got to be a name for this logical fallacy

Re:Type-safe HTML templating in Zig by drupe on Monday October 12, 2026 @09:12AM (#50055953)
A "slippery slope" fallacy might be what you're thinking of.
Re:Type-safe HTML templating in Zig by vulcan01 on Monday October 12, 2026 @01:57PM (#50060229)
It's almost a meta-slippery-slope fallacy, in that the specific slope is not specified; only the existence of the slope and its slipperiness is asserted.
Re:Type-safe HTML templating in Zig by preg_match on Monday October 12, 2026 @08:53PM (#50065170)
The slope we've observed over the decades is PHP. Which went from "basic HTML templating language" to "dotnet but you write $ everywhere". PHP has grown so much in complexity and feature-set that Symphony and the likes are legitimately dotnet-type. They make Go backends look low-level and primitive.
Re:Type-safe HTML templating in Zig by spartanatreyu on Monday October 12, 2026 @11:59PM (#50066497)
No

It's a repeated observation that keeps coming true. DSLs have a tendency to become turing complete over time.

- It happened to wikipedia's templating language

- It happened to PHP

- It happened to mod_rewrite

- It happened to server-side includes

- etc...

It just keeps happening.

In fact it's such a problem with infrastructure teams that use yaml/json configs that you see a lack of turing-completeness being advertised as a feature (see Dhall configuration language).

Re:Type-safe HTML templating in Zig by williamdclt on Tuesday October 13, 2026 @08:56AM (#50070953)
I don't disagree with "DSLs have a tendency to become turing complete over time", it's a well known fact.

But "we can't give something to users because otherwise they'll ask for other stuff" is not an argument. They're _already_ asking for stuff (templating) anyway. No one is suggesting that shutting users up is a reason to implement templating, it's the trade-offs of this feature that are debated. And if it gets implement then yes, users will certainly ask for more features, the trade-offs of which can be debated.

If you think that the line for HTML features is where we already are, you can present your arguments for why (tbh I'll probably agree). But "if you enable templating devs are then going to ask for more" isn't one.

Re:Type-safe HTML templating in Zig by spartanatreyu on Tuesday October 13, 2026 @07:28PM (#50080407)
The reality is that 90% of the features they ask for boils down to adding just a simple if statement, and as soon as a DSL has a practical if statement it becomes turing complete.

If the other 10% of features are implemented, then any further change makes the DSL turing complete.

It's not even really `if` by itself, conditionals are good enough. Templates with for loops that can check if an index is the first or last can implement if statements. Also templates that can nest other templates recursively with a max recursion depth can also implement if.

You have to go out of your way to avoid turing completeness if you want to avoid a complexity explosion.

Re:Type-safe HTML templating in Zig by everforward on Monday October 12, 2026 @10:39AM (#50057091)
It would tie in an additional feature with potential future incompatibilities, and it moves insecurities in templates to the client runtime where they’re more dangerous than compile/interpret time.

Eg some template feature creates a security issue and has to be disabled, which invalidates all the old HTML that used it.

There’s also just not a super great reason to do it. It’s not all that different from pre-templating like Hugo or doing it server-side like Django. You get to offload some compute, but HTML templating isn’t usually the bottleneck.

Re:Type-safe HTML templating in Zig by fergie on Tuesday October 13, 2026 @03:51AM (#50068192)
> It would tie in an additional feature with potential future incompatibilities

No offense but this is a bit of a non-argument that could be applied to just about any development in HTML.

> There’s also just not a super great reason to do it.

Most web dev frameworks exist in large part to solve the problem of templating. (yes, they do other stuff, but templating is the central problem that they are solving)

Re:Type-safe HTML templating in Zig by everforward on Tuesday October 13, 2026 @10:18AM (#50072198)
It does apply to all HTML dev, my point is more the idea that more features means more changes and more incompatible versions (and thus more strife).

HTML is actually shockingly backwards compatible. I very rarely see pages so old they won’t render. The main exception is basically exactly what I’m talking about: Flash and ActiveX, that had to be abandoned for security (and some poorly advised iframe stuff).

> Most web dev frameworks exist in large part to solve the problem of templating.

This might be an agree to disagree area. Most web dev frameworks I’ve seen exist to make dealing with state easier. They do templating because you have to put the state somewhere, but the magic is all in the state.

There are some that only do templating, but they’re pretty rare. Hugo or Jekyll come to mind, though “web dev framework” is probably overselling them.

There are also web components, which sound vaguely like what you’re talking about. They’re not crazy popular, but they exist and work. The security boundaries make it kind of a nightmare, I remember having to do something weird to inject Tailwind into them because they’re isolated from global CSS. The kind of things you have to do when securing templates at runtime instead of compile time.

Re:Type-safe HTML templating in Zig by fergie on Wednesday October 14, 2026 @02:32AM (#50083261)
Agree that handling state is also a big part of js frameworks.
Re:Type-safe HTML templating in Zig by messe on Monday October 12, 2026 @02:14AM (#50052006)

    <!-- #include file="header.html" -->
https://en.wikipedia.org/wiki/Server_Side_Includes
Re:Type-safe HTML templating in Zig by fergie on Monday October 12, 2026 @02:16AM (#50052022)
SSIs are not widely supported any more, and were never a part of the HTML standard

(but yes- I used these a lot like 25 years ago)

Re:Type-safe HTML templating in Zig by jonatron on Monday October 12, 2026 @05:30AM (#50053697)
From what I can tell, apache mod_include and nginx SSI are still included by default?
Re:Type-safe HTML templating in Zig by geoffmunn on Monday October 12, 2026 @03:16AM (#50052518)
Can I introduce you to iframes? Clunky but they do exactly what you are asking for.
Re:Type-safe HTML templating in Zig by brazukadev on Monday October 12, 2026 @06:09AM (#50054088)
and in a much safer way, sandboxed.
Re:Type-safe HTML templating in Zig by fergie on Tuesday October 13, 2026 @03:48AM (#50068181)
They embed webpages into other webpages and definitely have their place, and could arguably be used more, but they are definitely not a way to consolidate a single piece of HTML from constituent pieces.
Re:Type-safe HTML templating in Zig by icedchai on Monday October 12, 2026 @11:55AM (#50058245)
In the old days, we used to emulate this with a <script> tag that did a document.write ... yes, very hacky.
Re:Type-safe HTML templating in Zig by fergie on Tuesday October 13, 2026 @03:44AM (#50068146)
mate, I've been a full time web developer for 26 years, plus the time I spent at uni :)