Web Engine PreProcessing

This article contains the following topics:
casm1401
This article contains the following topics:
The web engine goes through two phases when processing an HTMPL file:
  • The preprocessing phase, when it reads the HTMPL file and any referenced files (including files referenced by PDM_INCLUDE and PDM_MACRO tags). The output from preprocessing is an entry in the web engine's internal cache.
  • The generation phase, where it reads the form from its cache and generates HTML. The output from generation is HTML delivered to the browser.
The pre-processing phase is typically done once for each form in the lifetime of the web engine. The generation phase is done each time a form is requested.
You can use the PDM_SET and PDM_EVAL tags during the preprocessor phase to generate and store information, such as HTML text, that the web engine can use in the generation phase.
Preprocessor Variables
Preprocessor variables begin with the string “$PRE.”. They are created and updated with the PDM_SET tag. This tag has the following syntax when used with a preprocessor variable:
<PDM_SET PRE.name[+]=value>
This tag assigns or updates a preprocessor variable, creating it if necessary. It is processed when the web engine encounters it while reading a form. Only the invariant PDM_IF statements affect PDM_SET of a preprocessor variable; others are ignored.
Invariant PDM_IF Detection
When parsing a form, the web engine detects invariant PDM_IF statements. An invariant PDM_IF is one whose argument consists entirely of literals, environment variables, constant properties, and preprocessor variables. When the web engine detects an invariant PDM_IF, it evaluates its condition immediately. This has the following effects:
  • PDM_SET and PDM_EVAL tags that are bypassed by an invariant PDM_IF are ignored. All other pdm_eval tags and PDM_SET tags referencing preprocessor variables are executed when processed, even if they are within a non-invariant PDM_IF.
  • Form variable references bypassed by an invariant PDM_IF are ignored, and their value is not fetched when the form is used. You can use this technique to improve the performance of a form. For example, if a form contains the following, the web engine fetches the value of $args.def before it displays the form:
    <PDM_IF "$env.NX_OTB_MARKET == "itil" && "$args.a" == 1> <h1>This is form $args.def</h1> </PDM_IF>
    However, if the following segment has been written, the web engine determines that the first PDM_IF is invariant, and retrieves the value of $args.def only if $NX_OTB_MARKET is “itil”.
    <PDM_IF "$env.NX_OTB_MARKET == "itil"> <PDM_IF "$args.a" == 1> <h1>This is form $args.def</h1> </PDM_IF> </PDM_IF>
PDM_EVAL Insert Text from a Preprocessor Variable
The PDM_EVAL tag inserts the value of a preprocessor variable into the input to the web engine parser. If used inside a macro, its effect is deferred until the macro completes.
The PDM_EVAL tag works similarly to PDM_INCLUDE or PDM_MACRO. It inserts the text into the parser at the point of the tag, exactly as if the value of its variable had been coded in place of the tag.
PDM_EVAL has the following syntax:
<PDM_EVAL text=PRE.name>
where PRE.name specifies the name of the preprocessor variable whose value is to be inserted into the web engine's input
Execution of the PDM_EVAL tag can be controlled by invariant PDM_IF statements.
On UNIX, the LIBPATH needs to be set before running the utility. Use pdm_task to perform this task. For example, before running the utility, input "pdm_task pdm_eval".