------------------------------------------------------------------------------- Apache SSI - Server-side includes (SHTML) as a templating language Tutorial Introduction https://httpd.apache.org/docs/2.4/howto/ssi.html SSI Expressions https://httpd.apache.org/docs/2.4/expr.html ------------------------------------------------------------------------------- WARNING: accessing variables in a #if changed in apache 2.4 making this incompatible with all other implementations of SSI! That is this produced errors in the server error log Could not parse expr "${var_name} in ...: Parse error near '$' Specifically to make this work you need to replace ${var_name} with v(var_name) Arrgghhhhh.... It is recommended you use the directive SSILegacyExprParser on in either or ".htaccess" files. Preferable the former as it only works with Apache v2.4 ------------------------------------------------------------------------------- I have used SHTML as a templating system for static web sites. Basically I run a local only Apache web server, and then use curl to convert specific SHTML pages into static HTML before uploading to the web service provider. This also lets me use the apache 'Fancy Directory Indexes' to generate directory "index.html" files, for the same static web server site. ------------------------------------------------------------------------------- Templated Includes Set variables before including a template file allows you to change the resulting HTML output. This could be used for make a template of an array of items in your HTML, allowing you to edit a single copy of the SHTML include. and so on. Inside the "object.shtml" file I can then use these variables... For example here is a small sub-section... .jpg" >.gif" WIDTH=120 HEIGHT=90 ALIGN=middle ALT="[photo]">

The "object.shtml" file include also unsets any optional variables such as "image" and "hart_obj" at the end, so it does not effect later file template includes. Such optional variables can, when not defined, 'fall back' to some built-in value if unset, such as a fixed value, or based on some other variable such as "object". See example of the HTML output of the above code usage in https://antofthy.gitlab.io/graphics/polyhedra/ ------------------------------------------------------------------------------- Comment your HTML, such that it is NOT included in HTML output That is adding a comment to a SHTML document but not including that comment in the generated HTML sent to clients. Note comments are sent out, just not displayed in the HTML displayed document. But they ARE SENT OUT in the HTML source. Best solution so far... And optionally add, though it is not really needed. Alturnative wrapp it in a SSI if construct Everything here is NOT included in the SSI templated file ------------------------------------------------------------------------------- Test if variable is set (fall backs) ASIDE: Note the way we avoid including lots of empty lines in the resulting HTML file. This extra blank lines are a pain of SSI but not really a problem. ------------------------------------------------------------------------------- Query Strings or Dynamic Web pages using SSI https://web.archive.org/web/20091125091246/http://www.daveoncode.com/2009/10/29/ You can extract things from query strings to determine what content to serve using something like... -------------------------------------------------------------------------------