Pages are main part of application and most of other files are related to them.
According to PG
variable value masser will try to find file to
process regarding path
from masser and application configuration.
It tries to find file according to PG value with .pg suffix (searches first in
paths from application and then from masser):
pages
/ filepages
/ fileBasic parts of pages are tags <?
and ?>
. Code between
these tags is processed, other code will be copied to output (see DeltaX::Page
for details).
You can use variants of these tags which are described in next sections.
Code in page is local; it means that function or variable in one page is not visible from other pages (in the same or other application), except of global variables and functions.
Example - application APP, file page1.pg:
... <? sub my_func { print 'page1'; } my_func(); ?> ...
... <? sub my_func { print 'page2'; } my_func(); ?> ...
<? ... ?>
Code between these two tags is supposed to be perl code and is without changes processed. Developer can assume existing of these global variables:
You don't need to use this variable, all functions from CGI
module are present, see use CGI qw(:all);
Next you can use following abbreviations which will be replaced:
PAR(id)
- value from application configurationTXT(id)
- text from actual language fileG(id)
- is replaced by $g{'id'}
<?= ... ?>
This variant is used for inserting value to actual place in page. Code
<?=$variable?>
is equivalent to <? print $variable; ?>
.
Example:
... <h1> <?='TXT(app_title)'?> </h1> ...
<?!---- ... ----?>
Comment will be ignored by masser and will not be even copied to output, it's completely thrown.
Opposite to HTML comment (<!---- ... ---->
), which
will be copied to output.
<?!include ...?>
Syntax: <?!include filename [def1[,def2...]]?>
Masser tries to find file with given name similar to pages (.pg):
include
/ fileinclude
/ fileCode from the file is included into parent file, so you can use any construction from it (include is used often in pages, so you can write to it code which can be written to page itself).
Masser currently not checks for recursive including, so it can lead to indefinite cycling of it!DefX definitions can be used to control included parts of .inc file using if, else and end constructs.
Example:
File test.pg: <?!include table print?> File table.inc: <?!use table?> <?!javascript table?> <?:if print?> <?!css table_print?> <?:else?> <?!css table_screen?> <?:end?>
<?!package ...?>
Syntax: <?!package filename?>
Masser tries to find file [filename].pkg similar to pages (.pg) this way:
package
/ filepackage
/ fileIt works similar to include, but is intended to create so-called packages - codes which consist of some parts (for example JavaScript code, CSS and module).
Example:
<?!include button.inc?> <?javascript button?> <?!css button?>
DefX definitions can be used to control included parts of .pkg file using if, else and end constructs.
Example:
File test.pg: <?!package table print?> File table.pkg: <?!use table?> <?!javascript table?> <?:if print?> <?!css table_print?> <?:else?> <?!css table_screen?> <?:end?>
<?!use ...?>
Syntax: <?!use filename
Masser tries to find file [filename].pm this way:
modules
/ filemodules
/ fileThis directive is used for including module to page. It can be placed anywhere in page, it's processed during compilation. Module which can be "used" using this directive is very similar to classic perl module, but you can use some masser features - read more about it in one of the following chapters.
<?!page_start ...?>
Syntax: <?!page_start [key1=>value1, key2=>value2, ...]?>
Writes start of HTML page (HTTP header and start of page to BODY tag). You can
use any parameter which is recognized by start_html()
function from CGI
module and these special:
This directive must be the first output of page, because it writes HTTP header. In other case server writes Internal Error = bad header.
Example:
... <?!page_start title=>'TXT(app_title)', bgcolor=>'#ffffff'?> ...
Important: This function includes JavaScript code and CSS to page, so if you
don't use it, tags javascript
and css
won't work!
<?!page_end?>
Syntax: <?!page_end?>
This directive writes end of page - end of FORM, BODY and HTML tags. It should be used as the last output of the page.
<?!javascript ...?>
Syntax: <?!javascript [ext:]filename?>
It requests that given JavaScript code to be included into page output. Code is normally written to HEAD tag of the page, but if use ext: prefix in the name, masser will include only reference to a file, otherwise it tries to find the file [filename].js this way:
javascript
/ filejavascript
/ fileIn JavaScript files you can use following constructions:
You cannot use it in files included with ext:
prefix - they are not
processed.
PAR([id])
is replaced by content of $conf{'id'}
(configuration)TXT([id])
is replaced by content of $txt{'id'} (text)GLB([id])
is replaced by content of $g{'id'} (global hash)Example - file example1.js:
alert('TXT(error_required)'); var num_items = PAR(max_results); for (var i=0; i<G(nusers); i++) { alert(i); }
<?!javascript example1?>
<?!css ...?>
Syntax: <?!css [ext:]filename?>
It requests that given file (it's content) to be included into page code (into HEAD tag). You can use ext: prefix to say to masser to not include code, only reference.
Because of CGI module limitation, you cannot insert more than one CSS file with ext: prefix. If you include more than one, only last will be included.Otherwise masser tries to find a file [filename].css this way (there is small difference in opposite to other findings: $schema [SCH parameter in page] is used to enable schema switching):
css
/ param('SCH')
/
filecss
/ filecss
/ param('SCH')
/ filecss
/ fileIn CSS files you can use following constructions:
You cannot use it in ext: prefixed files - they are not processed.
PAR([id])
is replaced by content of $conf{'id'}
(configuration)TXT([id])
is replaced by content of $txt{'id'} (text)GLB([id])
is replaced by content of $g{'id'} (global hash)Example - file example2.css:
BODY { background-image: url(GLB(img_dir)/backg1.gif); }
<?!css example2?>
<?!statement ...?>
Syntax: <?!statement [dbnum:]filename?>
Prepares given SQL command (using open_statement - see DeltaX::Database). Using dbnum prefix (number from 1 to 5) you can set in which database connection it is to be prepared (if application uses more than one database connection). If not set, statement is prepared in connection number 1.
Masser searches for file [filename].sql this way:
statement
/ filestatement
/ file_DATE_
inserts constructions for date_DATETIME_
inserts construction for date and timeSELECT * FROM cats_users WHERE pernr = ? AND last_chgp = _DATETIME_
<?!statement MY_STAT?> <?!statement 2:OTHER_STAT?> ... <? my $result = $db->perform_statement('MY_STAT'); ?>
<?!do ...?>
Syntax: <?!do filename [parameters]?>
At given place calls - differently from include it will not include whole code - given function, which code is in file filename. Masser tries to find it this way:
function
/ filefunction
/ fileFunction is global for the whole application, it's invisible for other running applications.
Example - file func.pl:
my (undef,$par1,$par2) = @_; # WARNING! The first argument is always application name! if ($par1 > $par2) { G(to_print) = 'TXT(is_greater)'; } elsif ($par1 < par2) { G(to_print) = 'TXT(is_lesser)'; } else { G(to_print) = 'TXT(is_equal)'; }
... <?!do func.pl 5,8?> <?=$g{'to_print'}?> ...
Actions are called according to OP
variable, which can be empty (no
action will be performed), one or more actions (separated by commas).
All actions are performed before pages.
Masser tries to find action according to OP with .ac suffix this way:
actions
/ fileactions
/ fileinclude
and statement
directives. It can output
text, but it's not recommended.