Setting Doctype
- The 'doctype' init function determines which DTD standard will be used when outputting the generated pages (e.g. HTML, XHTML or XML).
- The doctype setting directly affects how so-called 'un-paired' or 'void' tags are output. If the doctype is one of the XHTML or XML DTDs, all void tags will be output with the trailing '>' of the tag as ' />' instead of '>'. For example, '<br />' vs. '<br>'.
- Certain functions such as 'escapeHtml()' need to know the setting in order to know whether or not to use XHTML/XML-style open tags for unpaired and void tags such as <br>.
- Therefore it is important that this declaration occur before any use of these functions.
-
where:<dtd>:= one of:''<!DOCTYPE html>''''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">''''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">''''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN""http://www.w3.org/TR/html4/frameset.dtd">''''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">''''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">''''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">''''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">''
-
For convenience, the above <dtd> values can be expressed in
shorthand as:
-
'html'
'HTML'
'HTML 4.01 Strict'
'HTML 4.01 Transitional'
'HTML 4 T'
'HTML 4.01 Frameset'
'XHTML 1.0 Strict'
'XHTML 1.0 Transitional'
'XHTML 1.0 T'
'XHTML 1 T'
-
-
EXAMPLES:
-
doctype('html')
doctype('<!DOCTYPE html>')
doctype('XHTML 1.0 T')
doctype('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">')
-
-
For convenience, the above <dtd> values can be expressed in
shorthand as:
Other Functions
-
- Returns a string indicating the type of the value.
- EXAMPLE:
-
var $street1 = "1st Avenue";
// Prints "typeof(street1) = string"
print("typeof(street1) = ".+typeof($street1));
$street1.cross_street = "Main Street";
// Prints "typeof(street1) now = object"
print("typeof(street1) now = ".+typeof($street1));
-
- Returns a string containing the value of the batch environment variable, if it exists.
- EXAMPLE:
-
// Set $VER to the value of env var 'VER', or 'V1' if no env var value
if (!($VER = env("VER"))) $VER = 'V1';
-
- Returns an integer that is the integer portion of a float value, truncated toward 0.
- EXAMPLES:
-
var a = int(5.5); // a = 5
var c = int(-5.5); // c = -5
-
- Returns an integer that is the rounded value of a float value, rounded away from 0.
- EXAMPLES:
-
var a = round(5.5); // a = 6
var b = round(5.4); // b = 5
var c = round(-5.5); // c = -6
var d = round(-5.4); // d = -5
-
- Compares two values as numbers, and returns a number indicating their relative numeric values.
- Returns -1 if <value1> is less than <value2>
- Returns 1 if <value1> is greater than <value2>
- Returns 0 if they are equal
- This routine can be used by custom comparision functions used by sort().
- EXAMPLE:
-
var items = [[5,6], [3,4], [1,2]];
function mysortfn($a, $b) {return cmpNum($a[0], $b[0]);}
var items_sorted_as_numbers = sort(items, mysortfn);
Output-control Functions
-
- Modifies the default code-generator behavior for the cells of the scope.
-
If the 'one_line' option is specified, overrides the
'pp' 'pretty-print' command-line option if any,
forcing the code-generator to emit the cells of the scope and its
decendents as a single line.
This can be useful for emitting elements that really look best as
single lines, such as menu items.
- EXAMPLE:
-
<\
// Output nav bar as a single line
nav_bar { setOutputFormat('one_line'); }
\>
<nav_bar>
<item href="home.html">Home</item>
<item href="products.html">Products</item>
<item href="services.html">Services</item>
<item href="contactus.html">Contact Us</item>
</nav_bar>
-
If the 'plain' option is specified, overrides the
'pp' 'pretty-print' command-line option if any,
forcing the code-generator to emit the cells of the scope without
modification of indentation or spacing.
This can be useful for emitting elements such as text or code fragments
that are already aligned, preserving that alignment.
- EXAMPLE:
-
// Load contents of file 'test.hfl' as just ('raw') text,
// and output without changing indentation or spacing
p:1 {
include('test.hfl', 'raw');
setOutputFormat('plain');
}