by petepete · 4y ago · 0 comments
Apache has supported Server Side Includes forever. All you need to do is drop an 'include' in your HTML file and Apache will inject the contents in the right place.
<!--#include virtual="/header.html" -->
I don't know for certain but suspect other webservers will have similar functionality.https://httpd.apache.org/docs/current/howto/ssi.html
Edit:
IIS: https://docs.microsoft.com/en-us/iis/configuration/system.we...
Lighttpd: https://redmine.lighttpd.net/projects/1/wiki/docs_modssi
Nginx: https://nginx.org/en/docs/http/ngx_http_ssi_module.html
Tomcat: https://tomcat.apache.org/tomcat-7.0-doc/ssi-howto.html
If I received your code I would start by rolling my eyes, then by wasting some time learning Yet Another Technology (TM) that I will likely forget before the next time it comes handy.
In my experience, if you care about maintenance, one should stick to the worn path unless they have a good reason not to.
> It's cool that Apache also supports conditionals.
<...shudders...>
I wouldn't suggest using it for anything complex but it's ideal for inserting common headers and footers into static HTML.
Plus, it's using fewer technologies than anything you suggest. Less to maintain, less to go wrong. Sounds like a winner.
(didn't downvote you - I actually appreciate your sharing of your point of view)
Everything in the XML "ecosystem" (XSL, XPath, XDT, SOAP) is so unfriendly that I'm no longer surprised everyone is reinventing these concepts in (unfortunately) JSON these days.
An iframe with some CSS might however work to some degree.
Or you could use a frameset