NaviServer - programmable web server

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

# ns_adp_include(n) 4.99.8 naviserver "NaviServer Built-in Commands"

## Name

ns_adp_include - Parse an ADP file and return its output

## Table Of Contents

## Synopsis

- ns_adp_include ?-tcl? ?-cache seconds? ?-nocache? file ?arg ...?

## Description

This command parses the specified file as an ADP, 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 is the file containing the ADP to be parsed. If the file is not an absolute filename, the file is considered relative to the current ADP working directory which is the directory of the previously included file. Optional arguments (arg...) can be passed to the included ADP; see the ns_adp_argv command above for details on accessing the values of these variables. The optional -cache seconds argument specifies the time to cache the results of execution. All output generated by any scripts and included ADP's are saved for subsequent requests unless an included ADP has a -nocache option. The use of -cache and -nocache can be used to increase performance of ADP 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 substaintial, especially in cases where the cached content is the result of accessing a slow databases or web services. See the EXAMPLES section for an example of using cached output.

ADPs can be nested by including each other up to the maximum of 256 levels deep.

This command is only available from an ADP. Use ns_adp_parse to parse ADPs from outside the context of an ADP.

## COMMANDS

ns_adp_include ?-tcl? ?-cache seconds? ?-nocache? file ?arg ...?

  -tcl Given file is .tcl file and should be wrapped into ADP page -nocache Do not cache ADP page results -cache seconds Cache results for this amount of time

## EXAMPLES

        ###
        ### Example #1: Callee outputs directly to ADP output buffer.
        ###
        # In a.adp:
        <% ns_adp_include b.adp %>
        # In b.adp:
        <% ns_adp_puts &quot;Hello, world!&quot; %>
        ###
        ### Example #2: Caller outputs to ADP buffer.
        ###
        # In a.adp:
        <% ns_adp_puts ns_adp_include arg b.adp %>
        # In b.adp:
        <% return &quot;Hello, world!&quot; %>

## See Also

nsd

## Keywords

ADP