Apache::ASP::Syntax

<% Web Applications with Apache & mod_perl %>
| INTRO
| INSTALL
| CONFIG
% | SYNTAX
| EVENTS
| OBJECTS
| SSI
| SESSIONS
| XML/XSLT
| CGI
| PERLSCRIPT
| FAQ
| TUNING
| CREDITS
| SUPPORT
| SITES USING
| RESOURCES
| TODO
| CHANGES
| LICENSE
| EXAMPLES

SYNTAX

General | Editors
XMLSubs |

General

ASP embedding syntax allows one to embed code in html in 2 simple ways. The first is the <% xxx %> tag in which xxx is any valid perl code. The second is <%= xxx %> where xxx is some scalar value that will be inserted into the html directly. An easy print.

      A simple asp page would look like:

      <!-- sample here -->
      <html>
      <body>
      For loop incrementing font size: <p>
      <% for(1..5) { %>
    	<!-- iterated html text -->
    	<font size="<%=$_%>" > Size = <%=$_%> </font> <br>
      <% } %>
      </body>
      </html>
      <!-- end sample here -->

Notice that your perl code blocks can span any html. The for loop above iterates over the html without any special syntax.

XMLSubs

XMLSubs allows a developer to define custom handlers for HTML & XML tags, which can extend the natural syntax of the ASP environment. Configured like:

      PerlSetVar XMLSubsMatch site:\w+

A simple tag like:

      <site:header title="Page Title" />

can be constructed that could translate into:

      sub site::header {
          my $args = shift;
          print "<html><head><title>$args->{title}</title></head>\n";
          print "<body bgcolor=white>\n";
      }

Better yet, one can use this functionality to trap and post process embedded HTML & XML like:

      <site:page title="Page Title">
        ... some HTML here ...
      </site:page>

and then:

      sub site::page {
        my($args, $html) = @_;
        &site::header($args);
        $main::Response->Write($html);
        $main::Response->Write("</body></html>");
      }

Though this could be used to fully render XML documents, it was not built for this purpose, but to add powerful tag extensions to HTML development environments. For full XML rendering, you ought to try an XSLT approach, also supported by Apache::ASP.

Editors

As Apache::ASP supports a mixing of perl and HTML, any editor which supports development of one or the other would work well. The following editors are known to work well for developing Apache::ASP web sites:

     * Emacs, in perl or HTML modes.  For a mmm-mode config
       that mixes HTML & perl modes in a single buffer, check
       out the editors/mmm-asp-perl.el file in distribution.

     * Microsoft Frontpage

     * Vim, special syntax support with editors/aasp.vim file in distribution.

     * UltraEdit32 ( http://www.ultraedit.com/ ) has syntax highlighting,
       good macros and a configurable wordlist (so one can have syntax
       highlighting both for Perl and HTML).

Please feel free to suggest your favorite development environment for this list.
Copyright © 1998-2002, Joshua Chamas, Chamas Enterprises Inc.