NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_adp_parse(n) 5.0.0a naviserver "NaviServer Built-in Commands"

Name

ns_adp_parse - Parse an ADP file or string and return its output

Table Of Contents

Synopsis

Description

This function processes the specified ADP file or string and returns the result as a string. Processing a second ADP from inside an ADP is normally best done with ns_adp_include as that command resolves relative pathnames passed to it. Also note that ns_adp_parse will ignore any directives to turn on streaming. Tcl_Eval is used to evaluate the Tcl commands in the ADP.

Although the <% ... %> syntax is allowed in the string, if you have this embedded in an ADP, you have to be careful in constructing the string that you do not prematurely terminate an enclosing script.

COMMANDS

ns_adp_parse ?-cwd path? ?-file? ?-safe? ?-string? ?-tcl? ?args ...?

The option ?-cwd? can be used to set the current working directory for this ADP parse operation

The option ?-file? can be used to parse ADP contained in the given file. This use is similar to that of ns_adp_include except the result is returned by the command instead of automatically being appended to the output stream.

The option ?-safe? can be used to set the ADP safe flag.

The option ?-string? is provided for backwards compatibility, but does nothing since string mode is the default mode.

The option ?-tcl? can be provided to process a Tcl file.

Additional arguments can be provided, which are passed to the ADP evaluation. The arguments can be accessed within the ADP using the ns_adp_argc, ns_adp_argv, and ns_adp_bind_args commands.

If this call is a nested ADP evaluation (where one ADP calls another), an error will be thrown if the depth exceeds 256, the maximum number of nested ADP evaluations.

EXAMPLES

 % ns_adp_parse {2 + 2 = <%= [expr 2 + 2] %> !!!}
 2 + 2 = 4 !!!
 % ns_adp_parse -file foo.tcl

See Also

ns_adp, ns_adp_argc, ns_adp_argv, ns_adp_bind_args, ns_adp_include

Keywords

ADP, server built-in