3 ms·
Nice job! If only HTML had a serious templating system(no the template tag isn’t enough) that could be used without JavaScript, we won’t need any 3rd party syst
by hollowturtle 2y ago
Nice job! If only HTML had a serious templating system(no the template tag isn’t enough) that could be used without JavaScript, we won’t need any 3rd party system for assembling static sites. For example a mechanism for including partials with the <link> tag and refer them inside a <template> or directly into current html
- ZYbCRq22HbJ2y7 2y agohttps://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe https://developer.mozilla.org/en-US/docs/Web/HTML/Element/if... https://developer.mozilla.org/en-US/docs/Web/HTML/Element/portal https://developer.mozilla.org/en-US/docs/Web/HTML/Element/po... https://en.wikipedia.org/wiki/Server_Side_Includes https://en.wikipedia.org/wiki/Server_Side_Includes Also, other than to satisfy a purist desire, why do you need this? You can pre-render HTML quickly using a variety of template systems, and it would outperform what you are suggesting every time (from a client's perspective). I mean, think about the potential CSS resolution complexity, FOUC, etc.
- recursive 2y agoIn the 90s, we used Server Side Includes (SSI) for this. Probably still works.
- skyfaller 2y agoOne modern approach would be Caddy Server's templates, using Golang templating: https://caddyserver.com/docs/modules/http.handlers.templates https://caddyserver.com/docs/modules/http.handlers.templates The "include" function should do the job: {{include "path/to/file.html"}}
- ZYbCRq22HbJ2y7 2y agohttpd, nginx, a number of other servers support SSI https://nginx.org/en/docs/http/ngx_http_ssi_module.html https://nginx.org/en/docs/http/ngx_http_ssi_module.html Caddy chose not to, I guess? https://caddy.community/t/caddy-update-on-ssi-server-side-includes/400 https://caddy.community/t/caddy-update-on-ssi-server-side-in...
- alwillis 2y agoYou generally can’t use SSI on many popular platforms for static websites like Netlify, etc.
- someothherguyy 2y agoHowever, you could generate the static HTML easily and then publish it on those platforms, which is what many people do today (probably not often using SSI).
- nigel182 2y agoWe've got frames and iframes...
- Gualdrapo 2y ago(Chiming in because other people replying to you kept on the "iframe-like" part of the argument) Or serializing `<template>`s without needing JS. Like in lists (`<ol>`, `<ul>`, `<dl>`...). All in all `<template>`s are a nice thing to have, and I do use them a lot (like in my own portfolio), but it feels really lacking without JS.
- campak 2y agoYou could use HTMX.org ;)
- mixmastamyk 2y agoI mentioned the object tag elsewhere: https://news.ycombinator.com/item?id=42706227 https://news.ycombinator.com/item?id=42706227