NaviServer - programmable web server


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

ns_adp_parse(n) 4.99.5 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.

The -file file option 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.

-tcl flags can be passed to tell that given file is .tcl file which should be appropriately wrapped and parsed.

The -global and -local options are deprecated and ignored. All calls are now local to the current ADP call frame.

Additional arguments are passed to the ADP execution and can be accessed via the ns_adp_argc, ns_adp_argv, and ns_adp_bind_args commands.

You can pass optional arguments to the ADP. 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.

COMMANDS

ns_adp_parse ?-file file? ?-tcl? ?-safe? ?-savedresult varName? ?-cwd path? ?args ...?

EXAMPLES

   % ns_adp_parse {<% return [[expr 2 + 2]] %>}
   4
   % ns_adp_parse -file