Include-File
Statically includes a file. The file is read and included at page compile time. It is as if the
contents of the included file were textually typed into the page, at the location where the include
directive was encountered. The included file can therefore contain many molly page declarations,
which are parsed in the same way as-if they had been directly typed into the page.
If the file to be included is later modified (but the page itself is unchanged and hence not
recompiled), the updated included file will not be seen in the page. The parent page should be
updated or touch
' ed to
force it to recompile and hence load the included file again.
If the included file name is absolute (begins with a '/'), then it is relative to the servlet
webapp, otherwise it is relative to the current page.
Syntax
Include-File sections can appear anywhere in text sections.
[include-file filename]
Quotes around the filename are optional.
The filename of the statically included file can not contain expressions and hence cannot be generated dynamically. (in contrast to the
dynamic include directive).
Tag-Escape
To prevent the tag from being recognized, this tag can be escaped by prefixing the start tag with a
backslash: \[include-file
Example
An simple example of a file include.
[include-file 'test.file' ]
contents of test.file
Example
A code section that need to be included in various source
files (and is hence abstracted out to a seperate include
file). Note, if the include file contains a java variable
(in say, an expression or a code block), then that java
variable should have been declared prior to it's use. (either
earlier in the include file itself, as in the "debug" variable
below, or earlier in the main source file).
[include-file 'debug.m' ]
------ debug.m contains ---
[[
private boolean debug = true;
if (debug) {
//some actions here
}
]]
----------------------------
...the results of the include file
(which can vary) here..