NaviServer - programmable web server
4.99  5.0

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

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

Name

ns_adp_include - Parse an ADP file and return its output

Table Of Contents

Synopsis

Description

This command includes an ADP file in some other ADP file. ADP files can be nested by including each other up to the maximum of 256 levels deep.

This command is only applicable while parsing an ADP file. Use ns_adp_parse to parse ADPs from outside the context of an ADP.

COMMANDS

ns_adp_include ?-cache time? ?-nocache? ?-tcl? ?--? filename ?arg ...?

Includes the content of an ADP file, including the text blocks and any output generated by script blocks in the current output buffer. The execution occurs in a new call frame with private local variables similar to a Tcl procedure. The filename can be absolute or will be considered relative to the current ADP working directory which is the directory of the previously included file.

The optional -cache argument specifies the time to cache the results of execution. All output generated by any scripts and included ADP files are saved for subsequent requests unless an included ADP file has a -nocache option. The use of -cache and -nocache can be used to increase performance of ADP files used to generated a mix of personalized, non-cacheable, content and shared content which changes more slowly. Under high load, the performance improvement can be substantial, especially in cases where the cached content is the result of accessing a slow databases or web services.

The option -tcl can be used to wrap the .tcl file given by filename on the fly by an ADP page.

The optional arguments are passed to the included adp page, and can be accessed there by the ns_adp_argc, ns_adp_argv, and ns_adp_bind_args functions.

EXAMPLES

 ###
 ### Example: ADP file "a.adp" includes ADP file "b.adp"
 ###
 
 # In a.adp:
 begin of a.adp<br>
 <% ns_adp_include b.adp %>
 end of a.adp<br>
 
 # In b.adp:
 begin of b.adp<br>
 ...<br>
 <% ns_adp_puts "Hello, world!" %><br>
 ...<br>    
 end of b.adp<br>
 # Including ADP file a.adp:
 begin of a.adp<br>
 <% ns_adp_include b.adp 1 2 3%>
 end of a.adp<br>
 
 # Included ADP file b.adp:
 begin of b.adp<br>
 ...<br>
 <% ns_adp_puts "Arguments: [ns_adp_argv]" %><br>
 <%
   ns_adp_bind_args x y z
   ns_adp_puts "x=$x y=$y z=$z"      ;# => {1 2 3}
 %>
 ...<br>
 end of b.adp<br>

See Also

ns_adp, ns_adp_abort, ns_adp_append, ns_adp_argc, ns_adp_argv, ns_adp_bind_args, ns_adp_break, ns_adp_debug, ns_adp_dir, ns_adp_dump, ns_adp_exception, ns_adp_mimetype, ns_adp_parse, ns_adp_puts, ns_adp_register, ns_adp_return, ns_adp_stats, ns_adp_tell, ns_adp_trunc, ns_time

Keywords

ADP, server built-in