template::template_tag_include_helper_code (private)
template::template_tag_include_helper_code [ -command command ] \ [ -src src ] [ -ds_avail_p ds_avail_p ]
Defined in packages/acs-templating/tcl/tag-init.tcl
- Switches:
- -command
(optional)- -src
(optional)- -ds_avail_p
(defaults to"0"
) (optional)- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: if {$ds_avail_p} { set __DS_CODE__ { if {[info exists ::ds_enabled_p] && [info exists ::ds_collection_enabled_p] } { set __include_errors {} ns_cache get ds_page_bits [ad_conn request]:error __include_errors ns_cache set ds_page_bits [ad_conn request]:error [lappend __include_errors [list "__SRC__" $::errorInfo]] } } } else { set __DS_CODE__ "" } # Handle errors in the included snippet the following way: # - script-aborts are passed to the upper levels via "ad_try". # - If the included snippet leads to an error, include # it in the result and log it in the error log set snippet { ad_try { append __adp_output [__COMMAND__] } on error {errorMsg} { set templateFile [template::util::url_to_file __SRC__ $__adp_stub] append __adp_output "Error in include template \"$templateFile\": [ns_quotehtml $errorMsg]" # JCD: If we have the ds_page_bits cache maybe save the error for later __DS_CODE__ ad_log Error "Error in include template \"$templateFile\": $errorMsg" } } # # In order to avoid potential problems with substitution # patterns containing ampersand or backslashes, we use here a # scripted, purely string based substitution (which applies only # at "compilation time", therefore, performance is less critical. # # We have still to protect the case, that the passed-in $src # contains "__COMMAND__" which has to be protected. The # __DS_CODE__ is under our control, the content of __COMMAND__ # will not be substituted. # set containsMagicString [regsub -all __COMMAND__ $src \u0001 __SRC__] set __COMMAND__ $command foreach v {__DS_CODE__ __SRC__ __COMMAND__} { set startPos 0 set s "" set l [string length $v] while {1} { set p [string first $v $snippet $startPos] if {$p == -1} { append s [string range $snippet $startPos end] break } append s [string range $snippet $startPos $p-1] [set $v] set startPos $p incr startPos $l } #ns_log notice "=== include SNIPPET after $v substitution\n$s" set snippet $s } if {$containsMagicString} { regsub -all \u0001 $snippet __COMMAND__ snippet } #ns_log notice "final include SNIPPET\n$snippet" return $snippetXQL Not present: Generic, PostgreSQL, Oracle