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 {} chunk @@ -519,7 +519,7 @@ # recursively parse the template adp_compile_chunk $chunk - # ensure that code returns with the output + # ensure that code returns with the output lappend parse_list "set __adp_output" # the parse list now contains the code @@ -529,7 +529,7 @@ # Substitute #foo# message keys with values from the message catalog - # Since messages may read the variables of the adp page they go trough + # Since messages may read the variables of the adp page they go through # expand_percentage_signs which amongst other things does an uplevel subst while {[regsub -all \ {([^\\])\#([-a-zA-Z0-9_:]+[.][-a-zA-Z0-9_:]+)\#} \ @@ -547,7 +547,7 @@ while {[regsub -all [template::adp_array_variable_regexp_noquote] $code {\1[lang::util::localize $\2(\3)]} code]} {} while {[regsub -all [template::adp_array_variable_regexp_noi18n] $code {\1[ns_quotehtml $\2(\3)]} code]} {} while {[regsub -all [template::adp_array_variable_regexp_literal] $code {\1$\2(\3)} code]} {} - # + # # Some aolservers have broken implementations of ns_quotehtml # (returning for the empty string input a one byte output). If this # happens, we fall back to the "manual" ad_quotehtml. However, we @@ -579,10 +579,10 @@ } ad_proc -public template::adp_array_variable_regexp {} { - The regexp pattern used to find adp array variables in + The regexp pattern used to find adp array variables in a piece of text (i.e. @array_name.variable_name@). Captures the character preceding the first @ in \1, the array_name in \2, and variable_name in \3 - + @author Peter Marklund (peter@collaboraid.biz) @creation-date 25 October 2002 } { @@ -618,7 +618,7 @@ ad_proc -public template::adp_variable_regexp {} { The regexp pattern used to find adp variables in - a piece of text, i.e. occurrences of @variable_name@. + a piece of text, i.e. occurrences of @variable_name@. Captures the character preceding the first @ in \1 and the variable_name in \2. @@ -686,7 +686,7 @@ } ad_proc -private template::adp_quote_chunk { chunk_var_name quoted_var_name } { - Quotes (precedes by backslash) all square brackets, curly braces, + Quotes (precedes by backslash) all square brackets, curly braces, double quotes, backslashes, and dollar signs in a chunk of adp. @param chunk_var_name The name of the variable to quote @@ -718,8 +718,8 @@ @param code A line of Tcl code @option nobreak Flag indicating that code should be appended to the - current last line rather than adding a new line, for - cases where code must continue on the same line, such + current last line rather than adding a new line, for + cases where code must continue on the same line, such as the else tag } { if { [string is space $code] } { return } @@ -771,8 +771,8 @@ ns_adp_trunc } -ad_proc -private template::tag_attribute { - tag +ad_proc -private template::tag_attribute { + tag attribute } { Return an attribute from a tag that has already been processed. @@ -789,7 +789,7 @@ ad_proc -private template::current_tag {} { Return the top level tag from the stack. - + @author Lee Denison (lee@runtime-collective.com) @creation-date 2002-01-30 @@ -800,11 +800,11 @@ return [lindex $tag_stack end 1] } -ad_proc -private template::enclosing_tag { - tag +ad_proc -private template::enclosing_tag { + tag } { - Reach back into the tag stack for the last enclosing instance of a tag. - + Reach back into the tag stack for the last enclosing instance of a tag. + Typically used where the usage of a tag depends on its context, such as the "group" tag within a "multiple" tag. @@ -841,8 +841,8 @@ @param tag The name of the tag. @param params The ns_set passed to the tag handler. @param name The name of the attribute. - @param default A default value to return if the the attribute is - not specified in the template. A default value of + @param default A default value to return if the attribute is + not specified in the template. A default value of "ERROR" will cause the proc to throw an error if the attribute wasn't supplied.