Index: openacs-4/packages/acs-templating/tcl/parse-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/parse-procs.tcl,v diff -u -r1.61 -r1.62 --- openacs-4/packages/acs-templating/tcl/parse-procs.tcl 6 Apr 2018 13:56:20 -0000 1.61 +++ openacs-4/packages/acs-templating/tcl/parse-procs.tcl 24 Apr 2018 17:45:41 -0000 1.62 @@ -30,7 +30,7 @@ types:
bookshelf::book::get -book_id $book_id -array bookdata - set body [template::adp_include /packages/bookshelf/lib/one-book \ + set body [template::adp_include /packages/bookshelf/lib/one-book \ [list &book "bookdata" base $base style feed]]@@ -65,14 +65,14 @@ ad_proc -private template::adp_parse { __adp_stub __args } { Execute procedures to prepare data sources and then to output - template. Assumes adp_level is set on entry. in general the - public version template::adp_include should be used for generating + template. Assumes adp_level is set on entry. in general the + public version template::adp_include should be used for generating strings from adp files. @param __adp_stub The root (without the file extension) of the absolute path to the template and associated code. - @param __args One list containing any number of key-value pairs - passed to an included template from its container. + @param __args One list containing any number of key-value pairs + passed to an included template from its container. All data sources may be passed by reference. @see template::adp_include } { @@ -99,13 +99,13 @@ set $__key $__value } } - + # set the stack frame at which the template is being parsed so that # other procedures can reference variables cleanly lappend ::template::parse_level [info level] - + # execute the code to prepare the data sources for a template - set return_code [catch { + set return_code [catch { set found_script_p [adp_prepare] # if we get here, adp_prepare ran without throwing an error. @@ -196,9 +196,9 @@ return -code error -errorinfo $s_errorInfo -errorcode $s_errorCode $return_value } default { - if {$return_value eq "ADP_ABORT"} { + if {$return_value eq "ADP_ABORT"} { # return without rendering any HTML if the code aborts - return "" + return "" } else { return -code $return_code $return_value } @@ -219,11 +219,11 @@ if { [regexp $__adp_expr $__adp_value __adp_x __adp_name] } { upvar #$__adp_level $__adp_name $__adp_key - if { ! [array exists $__adp_key] } { + if { ! [array exists $__adp_key] } { upvar #$__adp_level $__adp_name:rowcount $__adp_key:rowcount - if { [info exists $__adp_key:rowcount] } { + if { [info exists $__adp_key:rowcount] } { set size [set $__adp_key:rowcount] @@ -233,7 +233,7 @@ } } } else { - set $__adp_key $__adp_value + set $__adp_key $__adp_value } } } @@ -242,8 +242,8 @@ ad_proc -public template::adp_abort {} { Terminates processing of a template and throws away all output. -} { - error ADP_ABORT +} { + error ADP_ABORT } ad_proc -public template::adp_eval { coderef } { @@ -270,7 +270,7 @@ @param up A relative reference to the "parse level" of interest. Useful in the context of an included template to reach into the stack frame in which the container template is being parsed, for - accessing data sources or other objects. The default is the + accessing data sources or other objects. The default is the highest parse level. @return A number, as returned by [info level], representing the stack frame @@ -332,8 +332,8 @@ #adp_abort return 0 } - - # if the file has changed than prepare again + + # if the file has changed then prepare again if { $__adp_stub ne $__adp_remember_stub } { adp_prepare; # propagate result up } { return 1 } @@ -352,7 +352,7 @@ initial code, so that each "skin" may reference additional specific data or logic as necessary. - @param path The root (sans file extension) of the absolute path to the + @param path The root (sans file extension) of the absolute path to the next template to parse. } { set level [adp_level] @@ -372,7 +372,7 @@ @param type Either ADP (template) or Tcl (code) @param file_stub The root (sans file extension) of the absolute path to the .adp or .tcl file to source. -} { +} { # this will return the name of the proc if it exists set proc_name [info commands ::template::mtimes::${type}::$file_stub] @@ -381,7 +381,7 @@ if {$proc_name eq "" || $refresh_cache ne "never" } { set mtime [file mtime $file_stub.$type] - if {$proc_name eq "" + if {$proc_name eq "" || $mtime != [$proc_name] || $refresh_cache eq "always"} { @@ -398,19 +398,19 @@ } # wrap the code for both types of files within an uplevel in - # the declared procedure, so that data sources are set in the + # 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 + # Here we add profiling calls if developer support exists on the # system. - if {[info commands ::ds_enabled_p] ne ""} { + if {[info commands ::ds_enabled_p] ne ""} { proc ::template::code::${type}::$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 { + } else { proc ::template::code::${type}::$file_stub {} " uplevel { $code @@ -437,10 +437,10 @@ set remaining_message $message set formatted_message "" while { [regexp [lang::message::embedded_vars_regexp] $remaining_message match before_percent percent_match remaining_message] } { - append formatted_message $before_percent + append formatted_message $before_percent if {$percent_match eq "%%"} { - # A quoted percentage sing + # A quoted percentage sign set substitution "%" } else { # An embedded variable @@ -456,11 +456,11 @@ # It's either an array variable or a Tcl variable # array variables # TODO: ad_quotehtml - # TODO: lang::util::localize - regsub -all {[\]\[\{\}\"]\\$} $substitution {\\&} substitution + # TODO: lang::util::localize + regsub -all {[\]\[\{\}\"]\\$} $substitution {\\&} substitution if { [regexp {^%([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)%$} $substitution match arr key] } { # the array key name is substitured by the Tcl parser s - regsub -all {[\]\[\{\}\"]\\$} $key {\\&} key + regsub -all {[\]\[\{\}\"]\\$} $key {\\&} key set command "set ${arr}(${key})" set substitution [uplevel $command] } @@ -503,7 +503,7 @@ set chunk $string } - # substitute <% ... %> blocks with registered tags so they can be handled + # substitute <% ... %> blocks with registered tags so they can be handled # by our proc rather than evaluated. regsub -all {<%} $chunk {