Search code examples
apachecgissi

Apache SSI commands add whitespace all over my HTML


This is the current state:

HTML FILE:
<!--#set var="header-title" value="Help - Frequently Asked Questions - FAQ" -->
<!--#set var="header-description" value="Answers to common questions about ..." -->
<!--#include virtual="includes/header-basic.htm" -->

INCLUDE FILE:
<!--#if expr="" -->
  Variables:
    header-title
    header-description
<!--#endif -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" />
<head>
...

RENDERED HTML:



<!DOCTYPE... (output starts here after several blank lines)

But I would like to squeeze the whitespace out of the rendered HTML. Is this possible? Also, I used hexdump to confirm I do not have UTF8 BOM in my file.


Solution

  • Thanks to (Ivan Shmakov) comp.infosystems.www.servers.unix. One approach is:

    <!--#set var="header-title" value="Help - Frequently Asked Questions - FAQ" 
    --><!--#set var="header-description" value="Answers to common questions about ..." 
    --><!--#include virtual="includes/header-basic.htm" --> 
    

    Also, another option (undocumented Apache behavior?) is to combine set directives:

    <!--#set 
      var="header-title" value="Help - Frequently Asked Questions - FAQ"
      var="header-description" value="Answers to common questions about..."
    --><!--#include virtual="includes/header-basic.htm" -->