3 ms·
Why can't HTML some kind of templating system, or even simple includes? Then I wouldn't need to use a static generator and could just author HTML directly. e.
by Evidlo 6y ago
Why can't HTML some kind of templating system, or even simple includes? Then I wouldn't need to use a static generator and could just author HTML directly.
e.g. (with hypothetical <extends> and <block> tags)
template.html
<!doctype html>
<html>
<h1>My Fancy Blog</h1>
<block main/>
</html>
index.html
<extends "template.html">
<block main>
<body>
Hello world
</body>
</block>
Maybe this would compromise browser performance or add some kind of vulnerability, but authoring DRY HTML directly is my fantasy
- crazypython 6y agoIt's called XSLT
- err4nt 6y agoLook into custom elements and web components, HTML already has amazing stuff built in, supported in every browser, and maybe even being used on some of your favourite sites!
- progval 6y ago> Why can't HTML some kind of templating system, or even simple includes? XHTML does, it's XSLT. For example: <?xml version='1.0' encoding='ASCII'?> <?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?> <root> <title>Page Title</title> <block name="main"> <article xmlns="http://www.w3.org/1999/xhtml"> <p>Hello world</p> </article> </block> </root> With this in stylesheet.xsl: <?xml version="1.0" encoding="ASCII"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/root"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <head> <title><xsl:value-of select="title" /></title> </head> <body> <h1>My Fancy Blog</h1> <xsl:copy-of select="block[@name='main']/xhtml:article" /> </body> </html> </xsl:template> </xsl:stylesheet> And it's supported by all major browsers. Probably even IE6.
- steren 6y agoNever again I will touch XSLT. That's how I dumped my wordpress to HTML. I regretted it. https://github.com/steren/wordpress-to-html https://github.com/steren/wordpress-to-html
- sseagull 6y agoNot exactly HTML, but webservers typically support server-side includes (SSI). https://en.wikipedia.org/wiki/Server_Side_Includes https://en.wikipedia.org/wiki/Server_Side_Includes