MML Documentation

Reference

Configuration File

The configuration file is divided into sections headed by a section name in square brackets. Each section contains one or more name=value pairs setting various settings relating to that section.

main section

defaultstyle
This sets the default style used for pages which don't otherwise override it with something else. This defaults to 'default' if not specified.
gzipresponse
With this enabled, presuming the perl module Compress::Zlib is installed, MML will gzip-encode the response if the client claims to support it. Not yet supported.
becacheable
With this enabled, the MML processor will do its best to make the semi-static content it is serving be cachable, by adding date headers and responding to If-Modified-Since headers. Not yet supported.
nohtmlparse
With this enabled, the MML processor will not parse the HTML in your body content. This might speed things up a little, but you lose custom tags and MML's little attempt at fixing broken HTML that might break templates.

codeblocks

deny_code
If set on, this will stop MML running code anywhere, including in templates.
initscript
Sets a script to be run before MML runs any code blocks to be found on the page. This can be used to initialise modules and set global perl variables. See the section on code blocks in the usage section for more details.

caching

The caching feature is not yet implemented. Watch this space.

path_/virtualdirectory/

Settings in path_ sections apply to the virtual path specified in the section name. Virtual paths are what the user sees the website to be structured as, rather than how the local filesystem sees it.

deny_code
If set on, MML will not run any code blocks within this directory.
deny_all
If set on, MML will refuse to render any MML documents within this directory. A 403 Forbidden response will be created.
style
Set an alternative style to apply to MML documents within this directory.

System Variables

These all have the SYS: prefix, and are set by MML to contain different parts of the source document.

SYS:TITLE The title specified in the MML document.
SYS:HEAD Optional extra header code specified in the MML document.
SYS:BODY The content of the MML document, as specified in the body section.

Environment Variables

These are supplied by the web server as part of the CGI transaction, so can and do vary from server to server. Here are some more commonly-used variables:

ENV:SERVER_NAME The hostname of the web server. Useful in creating canonical links.
ENV:REMOTE_ADDR The IP address of the client making the request.
ENV:REMOTE_USER When a document is protected by HTTP authentication, this variable contains the username used to log in.
ENV:HTTP_USER_AGENT The text supplied by client software to identify it.
ENV:HTTP_otherstuff HTTP headers supplied by the client are mapped on to HTTP_ variables.
ENV:SERVER_SOFTWARE A string provided by the web server to identify it.
ENV:REQUEST_URI The path portion of the URL for the MML document being processed.

Time Variables

Todo: write this section.

Embedded Perl Convenience Stuff

MML provides some variables and functions which allow you to do things commonly done in web-based scripting, but which perl doesn't normally provide easy access to.

Hashes

MML provides some hashes containing things that might be useful in embedded code...

%MML::Var All of the user-defined MML variables that have been set for this document and its associated style.
%MML::SysVar Environment variables as provided by the web server. Equivalent to %ENV, but provided for completeness.
%MML::Form Form variables as supplied by the client in either the entity body (a POST request) or in the URL (a GET request). Multiple values are separated by a null character (\0).
%MML::Cookies All of the cookies the client sent for this document.

Functions

The following functions are provided for convenience...

MML::escapehtml($text) Returns the contents of $text with all HTML special characters escaped. This string is suitable for insertion into HTML attributes or tags.
MML::addheader($name,$value) Adds a HTTP header to the response. This function is only available within initscripts.
MML::formdate($format,$ctime) Formats the time/date specified as a UNIX timestamp in $ctime (or, if omitted, the current time) into a string in the specified format. Format string is mostly identical to SSI date formatting.
MML::urldecode($text) Decodes a string in www-form-urlencoded format and returns the result.
MML::urlencode($text) Returns a string suitable for inclusion in a URL.
MML::duration($numberofseconds) Takes a number of seconds as a parameter and returns that value in a more appropriate unit along with the name of that unit, eg: "5 minutes".
MML::documentinfo($type) Returns information about the current document. $type can be lastmod, created, httppath or localpath