Page Content File:

This is the page-specific source file, which defines the main content as %PAGE_BODY%.

NOTE: All of the files listed below are renderings of the current sources, generated using the pphtml -esc command-line option

#define %TITLE%                     pphtml HTML Preprocessor
#define %ROOT_DIR%                  ..\..
#define %HIT_COUNTER%               pphtml
#define %BODY_HEIGHT%               400px
#define %KEYWORDS%                  preprocessor, pre-processor, html, perl, free, command-line, picture, gallery, downloads, escape
#define %NAVCURR%                   3
#include "config.shared.txt"
#define %NAVLINK2_NAME%             Downloads
#define %NAVLINK2%                  index.html
#define %NAVLINK3_NAME%             pphtml
#define %NAVLINK3%                  pphtml.html
#define %NAVLINK4_NAME%             GenPics
#define %NAVLINK4%                  GenPics.html
#define %TEMPLATE%                  %TEMPLATE_DIR%\Base3.htmp
#define_block %PAGE_BODY%
#---------------------------------------------------------------------
      <div class="body_content" style="position: relative; margin:  0px 20px; padding: 10px;">
        <h2>PPHTML: AN HTML PREPROCESSOR</h2>
        <p>%PPHTML% is a simple command-line preprocessor for HTML files, written in Perl.  
          Its purpose is to make it easy to extract blocks of
          html code into template segments, and then re-assemble them into full html files.  
          Perhaps its most striking feature is the ability to %E1%escape HTML characters%E0% so that you can
          include sample HTML code in your web pages without modification.
          It can also generate simple picture galleries. It is offered free of charge, and works on Windows sytems. 
          (To see the page source and template used to create this page, %HREF%(click here, "pphtml.sample.html").)
        </p>
        <p>It is intentionally a small and un-fancy tool, and all other features are %E1%add-ins%E0%.
          The concept is that unless we are doing something complex, we should be using simple tools
          that have clear functionality.
          And yet for those times that we are doing something special, we can %E1%extend that basic functionality%E0% 
          using %E1%add-ins%E0% to specific purposes.  But the basic tools should make almost no assumptions
          about what purpose they are being put to.
        </p>
        <p>The main problem with template formats is that the variable inner content
          is nested inside of several levels of shared html tags, and specific pages may need to modify the 
          outer shared layers.
          Most template systems solve this using a proprietary format for creating templates, which while it can be cool,
          is usually very inflexible once set up.
          And yet, usually all that is really needed is the ability to conditionally include template pieces.  
          In other words, some combination of #includes, #defines and #ifdefs.
        </p>
        <p>For that reason, the %PPHTML% preprocessor emulates 
          the C-Preprocessor syntax to a large degree, but with some extensions and a few limitations.
          Since all of the template pieces are fairly normal html files, the final set of files is always
          readable and maintainable, and can be used to create quite complex layouts.  
          But the best part is that you can retroactively create and use templates from existing web pages, 
          and you have the freedom to make the templates any way you wish.
        </p>
        <h3>SYNTAX</h3>
        <ul>
          <li>
            <p>Macro variables and macro pseudo-function names are enclosed in percent signs (%), ala batch files,
            so that variables may be used almost anywhere in an html file without accidentally expanding
            ordinary words or keywords.  Examples:
            </p>
            <div class="indented_text"><p class="code">
#escape_html
              #include "%TEMPLATE%"
              #define %WIDTH%                 110
              #define %DOCS%                  %USERPROFILE%\Documents
              <p style="width: %WIDTH%px;">Description</p>
              #define %HREF%(xyz)             <a href="xyz">xyz</a>
              #define %TITLE%                 Rainier Pictures
              <title>%TITLE%</title>
              #ifdef %VAR%
              #endif
#end_esc
              </p></div>
          </li>
          <li>
            <p>Supported standard preprocessor constructs:
            <div class="indented_text"><p class="code">
#escape_html
              #define %var% [value]
              #define %pseudo-fn%([arg-list])
              #undef %var%
              #include "path"
              #ifdef %var% .. #else .. #endif
              #ifndef %var% .. #else .. #endif
              #if <expr> .. #else .. #endif
#end_esc
              </p></div>
            </p>
          </li>
          <li>
            <p>Extended preprocessor constructs:
            <div class="indented_text"><p class="code">
#escape_html
              #define %var% \
                 ..
              #enddef
              #define_block %var%
                 ..
              #enddef %var%
              #include %var%
              #escape_html .. #end_esc
#end_esc
              </p></div>
            </p>
          </li>
        </ul>
        
        <h3>EXTENSIONS</h3>
        <ul>
          <li>
            <p>Extended preprocessor constructs:
              <ul>
                <li>%E1%In-line escaping of HTML special characters%E0% allows you to include HTML code as regular text,
                  and have the browser display it as just text.  (%LIT%(">>")This page makes heavy use of this feature.)
                  <p class="code">
#escape_html
                  #escape_html
                    <p>THIS IS JUST TEXT</p>
                  #end_esc
                  
                    SO IS THIS: (%LIT%(">>")This page makes heavy use of this feature.)
#end_esc
                  </p>
                  </li>
                <li>%E1%Multi-line %C1%#defines%C0%%E0% without \'s at ends of each line.  Instead uses a terminating
                  %E1%%C1%#enddef%C0%%E0%, so you can define blocks of code without modification.
                  There are two syntaxes. The first has a backslash at the end of the first line.
                  The second has the keyword %E1%%C1%#define_block%C0%%E0% that requires that the matching
                  %C1%#enddef%C0% have the same variable name, but allows any number of #defines in between:<br>
                  <p class="code">
#escape_html
                    #define %var% \
                      ..
                    #enddef
                    
                    #define_block %var%
                      ..
                    #enddef %var%
#end_esc
                  </p>
                  </li>
                <li>An %E1%extended %C1%#include%C0%%E0% syntax that takes a %E1%macro variable%E0% as its
                  argument instead of a filename string, and expands it as an %C1%#include%C0% file.
                  This allows macros created by %E1%%C1%#define%C0%%E0% or %E1%%C1%#define_block%C0%%E0%
                  to contain %C1%#ifdefs%C0%, %C1%#includes%C0% or other %C1%#defines%C0% and have 
                  them expanded as if they were in a separate file.  
                  %E2%Combined with the multi-line %C1%#defines%C0% above, content files can supply multiple
                  html content sections to be inserted into a template, all in one file.%E0%
                  <p class="code">
#escape_html
                    #include %var%
#end_esc
                  </p>
                  </li>
                <li>%E1%Optional macro arguments%E0% allows macros to expand with a variable number of arguments,
                  and even re-arrange them.  The optional parameters are specified as '%E1%...%E0%' in the parameter list
                  and the expansion list.  The '...' parameter can be used anywhere any other parameter can be used.
                  For example:<br>
                  <p class="code">
#escape_html
                    #define %EMPH%(...)         <span class="emphasis">...</span>
                    #define %ADD_X%(...)        foo('x', ...)
                    #define %REV%(a, b, ...)    bar(..., b, a)
#end_esc
                  </p>
                  </li>
              </ul>
            </p>
          </li>
          <li>
            <p>%PPHTML% supports %E1%macro expansion within quoted strings%E0%.  This allows use of variables for
              file paths, tag values, etc.  For example:
            </p>
            <div class="indented_text"><p class="code">
#escape_html
                #ifdef %CSS%
                <link href="%STYLES_DIR%/%CSS%.css" rel="stylesheet" type="text/css" />
                #endif
#end_esc
              </p></div>
          </li>
          <li>
            <p>%PPHTML% simplifies %E1%template generation%E0% by allowing you to control whether templates fully
              or only partially expand.  
              This makes it possible to create master templates from sub-templates.  For example, you can set up
              standard components for a website, such as headers, footers, and navigation bars as sub-templates.
              Then you can create templates from these sub-templates, that specialize for different types of pages
              or content.  The main development is done using the templates, which only need to be updated when 
              the sub-templates change.
              </p>
          </li>
          <li>
            <p>%PPHTML% has an %E1%extension interface%E0%, so that you can create custom preprocessor functions
              as %E1%add-ins%E0%.  As an example, %PPHTML% includes the built-in extension %GENPICS_LINK%, which
              %E1%generates simple picture galleries%E0% as an html table.<br>
              </p>
          </li>
        </ul>
        <div style="margin-left: 350px;">
          <form action="pphtml.dl.html" method="get"><input type="submit" name="submit" value="download" /></form>
          </div>
        <p style="text-align: right;">Last Updated: 4/26/10</p>
        </div>
#---------------------------------------------------------------------
#enddef %PAGE_BODY%
#include "%TEMPLATE%"

Template File:

This is the shared template file "Base3.htmp", where the content is inserted via macro %PAGE_BODY%

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
#ifdef %HEAD_INIT%
    %HEAD_INIT%
#endif /* %HEAD_INIT% */
    <title>%TITLE%</title>
    <link href="%STYLES_DIR%/Base.css" rel="stylesheet" type="text/css" media="screen,print" />
    <link href="%STYLES_DIR%/Nav.css" rel="stylesheet" type="text/css" media="screen,print" />
#ifdef %CSS%
    <link href="%STYLES_DIR%/%CSS%.css" rel="stylesheet" type="text/css" media="screen,print" />
#endif /* %CSS% */
#ifdef %LOCAL_CSS%
    <link href="%LOCAL_CSS%.css" rel="stylesheet" type="text/css" media="screen,print" />
#endif /* %LOCAL_CSS% */
#ifdef %KEYWORDS%
    <meta name="keywords" content="%KEYWORDS%" /> 
#endif /* %KEYWORDS% */
    %SCRIPTS%
  </head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="shadow_left"> </td>
    <td class="header_column">%TITLE%
      </td>
    <td class="shadow_right"> </td>
    </tr>
  <tr>
    <td class="shadow_left"></td>
    <td class="horizontal_center">
<!--    NAV BAR -->
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="linkcontainer">
        <tr>
#ifndef %NAV1_INACTIVE%
          <td><div class="navigation"><a href="%NAVLINK1%" class="%NAVLINK1_CLASS%" %NAVCURR1%>%NAVLINK1_NAME%</a></div></td>
#else
          <td><div class="navigation"><div class="%NAVLINK1_CLASS%_inactive" %NAVCURR1%>%NAVLINK1_NAME%</div></div></td>
#endif
#ifndef %NAV2_INACTIVE%
          <td><div class="navigation"><a href="%NAVLINK2%" class="%NAVLINK2_CLASS%" %NAVCURR2%>%NAVLINK2_NAME%</a></div></td>
#else
          <td><div class="navigation"><div class="%NAVLINK2_CLASS%_inactive" %NAVCURR2%>%NAVLINK2_NAME%</div></div></td>
#endif
#ifndef %NAV3_INACTIVE%
          <td><div class="navigation"><a href="%NAVLINK3%" class="%NAVLINK3_CLASS%" %NAVCURR3%>%NAVLINK3_NAME%</a></div></td>
#else
          <td><div class="navigation"><div class="%NAVLINK3_CLASS%_inactive" %NAVCURR3%>%NAVLINK3_NAME%</div></div></td>
#endif
#ifndef %NAV4_INACTIVE%
          <td><div class="navigation"><a href="%NAVLINK4%" class="%NAVLINK4_CLASS%" %NAVCURR4%>%NAVLINK4_NAME%</a></div></td>
#else
          <td><div class="navigation"><div class="%NAVLINK4_CLASS%_inactive" %NAVCURR4%>%NAVLINK4_NAME%</div></div></td>
#endif
#ifndef %NAV5_INACTIVE%
          <td><div class="navigation"><a href="%NAVLINK5%" class="%NAVLINK5_CLASS%" %NAVCURR5%>%NAVLINK5_NAME%</a></div></td>
#else
          <td><div class="navigation"><div class="%NAVLINK5_CLASS%_inactive" %NAVCURR5%>%NAVLINK5_NAME%</div></div></td>
#endif
          </tr>
        </table>
<!--    NAV BAR -->
      </td>
    <td class="shadow_right"></td>
    </tr>
  <tr>
    <td class="shadow_left"></td>
    <td class="below_header">%BELOW_HEADER%
      </td>
    <td class="shadow_right"></td>
    </tr>
  <tr>
    <td class="shadow_left"> </td>
#ifdef %BODY_HEIGHT%
    <td class="body_content_container" style="position: relative; height: %BODY_HEIGHT%;" %BODY_FORMAT%>
#else /* !%BODY_HEIGHT% */
    <td class="body_content_container" %BODY_FORMAT%>
#endif /* %BODY_HEIGHT% */
<!-- PAGE-SPECIFIC START -->
#include %PAGE_BODY%
<!-- PAGE-SPECIFIC END -->
      </td>
    <td class="shadow_right"> </td>
    </tr>
  <tr>
    <td class="shadow_left"> </td>
    <td class="middle_spacer"><div class="bottom_content"></div></td>
    <td class="shadow_right"> </td>
    </tr>
  <tr>
    <td class="shadow_left"> </td>
    <td class="bottom_link_container">
      <p>
      <a href="%ROOT%/index.html" class="bottom_link">Home</a> | 
      <a href="%ROOT%/Designs/index.html" class="bottom_link">Designs</a> | 
      <a href="%ROOT%/Machining/index.html" class="bottom_link">Machining</a> | 
      <a href="%ROOT%/School/index.html" class="bottom_link">School</a> | 
      <a href="%ROOT%/Downloads/index.html" class="bottom_link">Downloads</a> | 
      <a href="%ROOT%/Personal/PhotoGallery/index.html" class="bottom_link">Galleries</a> | 
      <a href="%ROOT%/ContactUs/index.html" class="bottom_link">Contact Us</a> 
      </p>
#ifdef %HIT_COUNTER%
      <p style="margin: -26px 30px 0px 700px; height: 26px;">
        <script language="JavaScript" type="text/javascript" src="/counter/counter.%HIT_COUNTER%.php4"></script>
      </p>
#endif /* %HIT_COUNTER% */
      </td>
    <td class="shadow_right"> </td>
    </tr>
  </table>
</body>
</html>

Local Configuration File:

This is the shared local configuration file "config.shared.txt", which defines several useful macros

#define %GP_VER%            1.2
#define %ROOT%              ..
#define %ROOT_DIR%          ..\..
#define %FILES_DIR%         Downloads\gen
#define %LOCAL_CSS%         Downloads
#define %STYLES_DIR%        ../Styles
#define %IMAGES_DIR%        Images
#define %PARENT_PAGE%       ../index.html
#define %HK%                %E1%HyperKey%E0%
#define %PPHTML%            %E1%pphtml%E0%
#define %GP%                %E1%genpics%E0%
#define %PPP%               %E1%ppp%E0%
#define %PPP_LINK%          %PPP_LINK2%(ppp)
#define %PPP_LINK2%(x)      <a href="ppp.html" class="inline_link">x</a>
#define %PPHTML_LINK%       %PPHTML_LINK2%(pphtml)
#define %PPHTML_LINK2%(x)   <a href="pphtml.html" class="inline_link">x</a>
#define %HKEY_LINK%         %HKEY_LINK2%(HyperKey)
#define %HKEY_LINK2%(x)     <a href="HyperKey.html" class="inline_link">x</a>
#define %GENPICS_LINK%      %GENPICS_LINK2%(GenPics)
#define %GENPICS_LINK2%(x)  <a href="GenPics.html" class="inline_link">x</a>
#define %DLS_LINK2%(x)      <a href="index.html" class="inline_link">x</a>
#include "..\..\Templates\init.htmp.txt"

... which includes:

Project Configuration File:

This is the shared project configuration file "init.htmp.txt", which defines macros used throughout the site.

#define %TEMPLATE_DIR%      %ROOT_DIR%\Templates
#define %SUBTEMPLATE_DIR%   %TEMPLATE_DIR%\Subtemplates
#ifdef %SET_THUMB_DIMS%
#define %THUMB_DIMS%                width="%THUMB_WIDTH%" height="%THUMB_HEIGHT%"
#endif /* %SET_THUMB_DIMS% */
#ifdef %USE_THUMB_PREFIX%
#define %THUMB_PREFIX%              thb_
#endif /* %USE_THUMB_PREFIX% */
#ifndef %NAVLINK1%
#define %NAVLINK1%                  %ROOT%/index.html
#endif
#ifndef %NAVLINK1_NAME%
#define %NAVLINK1_NAME%             Home
#endif
#ifndef %NAVLINK1_CLASS%
#define %NAVLINK1_CLASS%            main_link
#endif
#ifndef %NAVLINK2%
#define %NAVLINK2%                  %ROOT%/Designs/index.html
#endif
#ifndef %NAVLINK2_CLASS%
#define %NAVLINK2_CLASS%            main_link
#endif
#ifndef %NAVLINK2_NAME%
#define %NAVLINK2_NAME%             Designs
#endif
#ifndef %NAVLINK3%
#define %NAVLINK3%                  %ROOT%/Machining/index.html
#endif
#ifndef %NAVLINK3_NAME%
#define %NAVLINK3_NAME%             Machining
#endif
#ifndef %NAVLINK3_CLASS%
#define %NAVLINK3_CLASS%            main_link
#endif
#ifndef %NAVLINK4%
#define %NAVLINK4%                  %ROOT%/Downloads/index.html
#endif
#ifndef %NAVLINK4_NAME%
#define %NAVLINK4_NAME%             Downloads
#endif
#ifndef %NAVLINK4_CLASS%
#define %NAVLINK4_CLASS%            main_link
#endif
#ifndef %NAVLINK5%
#define %NAVLINK5%                  %ROOT%/ContactUs/index.html
#endif
#ifndef %NAVLINK5_NAME%
#define %NAVLINK5_NAME%             Contact Us
#endif
#ifndef %NAVLINK5_CLASS%
#define %NAVLINK5_CLASS%            main_link
#endif
#define %PHOTO_GAL_DIR%             %ROOT%/Personal/PhotoGallery
#define %NAVLINK_PHOTO_GAL%         %PHOTO_GAL_DIR%/index.html
#define %NAVLINK_RAINIER_GAL%       %PHOTO_GAL_DIR%/Rainier Pics/index.html
#define %NAVLINK_UTAH_GAL%          %PHOTO_GAL_DIR%/Utah Pics/index.html
#if %NAVCURR% == 1
#define %NAVCURR1%          id="nav_curr"
#define %NAV1_INACTIVE%
#endif
#if %NAVCURR% == 2
#define %NAVCURR2%          id="nav_curr"
#define %NAV2_INACTIVE%
#endif
#if %NAVCURR% == 3
#define %NAVCURR3%          id="nav_curr"
#define %NAV3_INACTIVE%
#endif
#if %NAVCURR% == 4
#define %NAVCURR4%          id="nav_curr"
#define %NAV4_INACTIVE%
#endif
#if %NAVCURR% == 5
#define %NAVCURR5%          id="nav_curr"
#define %NAV5_INACTIVE%
#endif
#define %E1%                <span class="emphasis">
#define %E2%                <span class="strong_emphasis">
#define %E_1%               <span class="weak_emphasis">
#define %Ered%              <span style="color: red">
#define %Eimp%              <span style="color: #ff0000">
#define %E0%                </span>
#define %HREF%(lab, link)   <a href=link>lab</a>
#define %C1%                <span class="inline_code">
#define %C0%                </span>
#define %V%(x)              %x%