template::adp_init (public)
template::adp_init type file_stub
Defined in packages/acs-templating/tcl/parse-procs.tcl
Ensures that both data source Tcl files and compiled ADP templates are wrapped in procedures in the current interpreter. Procedures are cached in byte code form in the interpreter, so this is more efficient than sourcing a Tcl file or parsing the template every time. Also checks the modification time on the source file to ensure that the procedure is up-to-date.
- Parameters:
- type (required)
- Either ADP (template) or Tcl (code)
- file_stub (required)
- The root (sans file extension) of the absolute path to the .adp or .tcl file to source.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- callgraph__bad_page_calls
Source code: # # Depending on the iconset, the result of the compiled template # might be different. So, cache per iconset # set cache [iconset]-$type # # Check, if the compiled proc exists already. # set proc_name [namespace which ::template::mtimes::${cache}::$file_stub] #ns_log notice "$type $file_stub -> '$proc_name'" set pkg_id [apm_package_id_from_key acs-templating] set refresh_cache [parameter::get -package_id $pkg_id -parameter RefreshCache -default "as needed"] if {$proc_name eq "" || $refresh_cache ne "never" } { set mtime [file mtime $file_stub.$type] if {$proc_name eq "" || $mtime != [$proc_name] || $refresh_cache eq "always"} { # # Either the procedure does not already exist or is not # up-to-date # namespace eval ::template::code::${cache} {} switch -exact $type { tcl { set code [template::util::read_file $file_stub.tcl] } default { set code [adp_compile -file $file_stub.$type] } } #ns_log notice "$type $file_stub -> compiled '$code'" # # Wrap the code for both types of files within an uplevel # in the declared procedure, so that data sources are set # in the same frame as the code that outputs the template. # # Here we add profiling calls if developer support exists # on the system. # if {[namespace which ::ds_enabled_p] ne ""} { proc ::template::code::${cache}::$file_stub {} "if {\[::ds_enabled_p\] && \[::ds_collection_enabled_p\] && \[::ds_profiling_enabled_p\]} { ds_profile start $file_stub.$type } uplevel { $code } if {\[::ds_enabled_p\] && \[::ds_collection_enabled_p\] &&\[::ds_profiling_enabled_p\]} { ds_profile stop $file_stub.$type }\n" } else { proc ::template::code::${cache}::$file_stub {} " uplevel { $code }\n" } namespace eval ::template::mtimes::${cache} {} proc ::template::mtimes::${cache}::$file_stub {} "return $mtime" } } return ::template::code::${cache}::$file_stubXQL Not present: Generic, PostgreSQL, Oracle