Difference between revisions of "Ns adp parse"

From AOLserver Wiki
Jump to navigation Jump to search
Line 17: Line 17:
 
: If you need to process a second ADP from inside an ADP, it is usually better to use [[ns_adp_include]], because 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.  
 
: If you need to process a second ADP from inside an ADP, it is usually better to use [[ns_adp_include]], because 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.  
  
: If you use the ''-string'' syntax, then ''arg'' is a string containing ADP syntax to be parsed.  Note that when you call this command with the ''-string'' syntax from inside an ADP, the string cannot contain the "<% ... %>" syntax.  The ''-string'' syntax is the default.
+
: If you use the ''-string'' syntax, then ''arg'' is a string containing ADP syntax to be parsed.  Note that when you call this command with the ''-string'' syntax from inside an ADP, the string cannot contain the "<% ... %>" syntax in versions of AOLserver prior to 4.5.  The ''-string'' syntax is the default.
  
 
: If you use the ''-file'' syntax, then ''arg'' is the absolute path to the file containing the ADP to be parsed.
 
: If you use the ''-file'' syntax, then ''arg'' is the absolute path to the file containing the ADP to be parsed.
Line 34: Line 34:
 
     % ns_adp_parse -file [[ns_info pageroot]]/index.adp
 
     % ns_adp_parse -file [[ns_info pageroot]]/index.adp
 
     ... output of index.adp ...
 
     ... output of index.adp ...
 +
 +
'''WARNING'''
 +
: In AOLserver versions prior to 4.5, -safe flag had no effect when used in combination with -file.  In addition, -safe restriction could be bypassed in either a string or file by using this syntax: <script runat=server>...</script>
  
 
'''SEE ALSO'''
 
'''SEE ALSO'''

Revision as of 00:59, 14 June 2010

Man page: http://aolserver.com/docs/tcl/ns_adp_parse.html


NAME

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

SYNOPSIS

ns_adp_parse ?-file|-string? ?-safe? arg ?arg ...?

DESCRIPTION

This command processes an ADP from either a file or a string, returning the output. The first arg specifies the filename or contains the string to parse, depending on -file or -string.
If you need to process a second ADP from inside an ADP, it is usually better to use ns_adp_include, because 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.
If you use the -string syntax, then arg is a string containing ADP syntax to be parsed. Note that when you call this command with the -string syntax from inside an ADP, the string cannot contain the "<% ... %>" syntax in versions of AOLserver prior to 4.5. The -string syntax is the default.
If you use the -file syntax, then arg is the absolute path to the file containing the ADP to be parsed.
If you specify the -safe flag, then only registered tags are executed; inline scripts using "<% ... %>" or "<%= ... %>" are ignored.
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.

EXAMPLES

   % ns_adp_parse -string {<% return expr 2 + 2 %>}
   4
   % ns_adp_parse -file ns_info pageroot/index.adp
   ... output of index.adp ...

WARNING

In AOLserver versions prior to 4.5, -safe flag had no effect when used in combination with -file. In addition, -safe restriction could be bypassed in either a string or file by using this syntax: <script runat=server>...</script>

SEE ALSO

ns_adp_abort, ns_adp_append, ns_adp_argc, ns_adp_argv, ns_adp_bind_args, ns_adp_break, ns_adp_debug, ns_adp_debuginit, ns_adp_dir, ns_adp_dump, ns_adp_eval, ns_adp_exception, ns_adp_include, ns_adp_mime, ns_adp_mimetype, ns_adp_puts, ns_adp_registeradp, ns_adp_registerproc, ns_adp_registertag, ns_adp_return, ns_adp_safeeval, ns_adp_stats, ns_adp_stream, ns_adp_tell, ns_adp_trunc

Category Documentation - Category Core Tcl API