Programmer / Developer GuideTemplating System : Developer Guide
Mini How ToStart a Tcl page as usual with
ad_page_contract. Be sure to pass a
-propertiesblock; this signals the use of templating. The Tcl page should fill the data sources you promised in the contract, and not write to the connection. At the end of your Tcl page, call
ad_return_template. The template system will look for an adp page with the file name stub you indicate (defaulting to the same stub as the Tcl page), process that, and deliver it to the client. The adp page can use the datasources defined in the Tcl page.
- User Guide
- Establishing data sources
- Creating templates
- Managing forms
- Handling errors
- See the "contract", "error", and "state" demos.
- Object and API Reference
- Template Markup Tag Reference
APIAfter the script for a page is executed, acs-templating processes the template, interpolating any data sources and executing the special tags. The resulting HTML page is written to the connection (i.e., returned to the user).
Normally, does nothing at all. With the
-stringoption you get the resulting HTML page returned as a string.
template argument is a path to a page
(tcl/adp file pair). Note that you don't supply the
".tcl" or ".adp" extension. It is resolved by
template::util::url_to_file (with the current
file stub as reference path) and passed to
template::set_file, to change the name of the page
being served currently. If it starts with a "/", it is
taken to be a path relative to the server root; otherwise it is a
filename relative to the directory of the Tcl script.
Normally, complaints about incorrect parameters are written
directly to the connection, and the script is aborted. With the
-return_errorsyou can name a variable into which to put any error messages as a list, and
ad_page_contractwill return in any case. You can then present the errors to the user in a templated page, consistent with the look and feel of the rest of your service. If there's no complaint,
ad_page_contractwon't touch the variable; typically it will stay undefined.
Christian Brechbühler Last modified: $Id: developer-guide.html,v 1.5 2017/08/07 23:48:02 gustafn Exp $