The ACS templating system has a reasonable number of tags. One tag
is called 'include' and is used to include another adp template in the
current template. Unfortunately, you have to pass all the variables
and values to the sub-template, so it is not very convenient.
It turns out to be fairly easy to add new tags. I added a tag
called 'read', for lack of a better name. What it does is to read a
sub-template and include it into the current template, without the
need to pass any variables. It also works recursively. Here is the
code, which should be placed in acs-templating/tcl/tag-init.tcl:
template_tag read { params } {
set source [ns_set iget $params src]
if {![string match "absolute" [file pathtype $source]]} {
set source [ns_normalizepath [ad_conn adp_root]/$source]
}
set chunk [template::util::read_file $source]
template::adp_compile_chunk $chunk
}
Problems include the fact that compiled templates are cached. Only
the mtime of the parent adp is used to determine if the template is
up-to-date. On a stable system, this should not be a problem. For
development, however, you need to touch parent.adp
You can use the tag as follows:
or
If using a relative path, you need to set ad_conn(adp_root) to
something useful:
global ad_conn
set ad_conn(adp_root) "/absolute/path/to"