Index: openacs-4/packages/acs-templating/tcl/tag-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/tag-init.tcl,v diff -u -r1.49.2.7 -r1.49.2.8 --- openacs-4/packages/acs-templating/tcl/tag-init.tcl 28 Dec 2021 13:40:03 -0000 1.49.2.7 +++ openacs-4/packages/acs-templating/tcl/tag-init.tcl 28 Dec 2021 13:54:01 -0000 1.49.2.8 @@ -19,12 +19,12 @@ template::tag tcl { chunk params } { - # if the chunk begins with = then add our own append - if { [string index $chunk 0] eq "=" } { - template::adp_append_code "append __adp_output [string range $chunk 1 end]" - } else { - template::adp_append_code $chunk - } + # if the chunk begins with = then add our own append + if { [string index $chunk 0] eq "=" } { + template::adp_append_code "append __adp_output [string range $chunk 1 end]" + } else { + template::adp_append_code $chunk + } } # Set a property for the template. Properties are primarily for the @@ -53,52 +53,52 @@ template::tag master { params } { - set src [ns_set iget $params src] - set slave_properties_p [template::get_attribute master $params slave-properties-p 0] + set src [ns_set iget $params src] + set slave_properties_p [template::get_attribute master $params slave-properties-p 0] - if {[template::util::is_true $slave_properties_p]} { - template::adp_append_code { - foreach {__key __value} $__args { - if {$__key ne "__adp_slave"} { - set __adp_properties($__key) $__value - } - } - } - } + if {[template::util::is_true $slave_properties_p]} { + template::adp_append_code { + foreach {__key __value} $__args { + if {$__key ne "__adp_slave"} { + set __adp_properties($__key) $__value + } + } + } + } - # default to the site-wide master - if {$src eq ""} { - set src {[parameter::get -package_id [ad_conn subsite_id] -parameter DefaultMaster -default "/www/default-master"]} - } + # default to the site-wide master + if {$src eq ""} { + set src {[parameter::get -package_id [ad_conn subsite_id] -parameter DefaultMaster -default "/www/default-master"]} + } - template::adp_append_code [subst -nocommands { - set __adp_master [template::util::master_to_file "$src" "\$__adp_stub"] - }] + template::adp_append_code [subst -nocommands { + set __adp_master [template::util::master_to_file "$src" "\$__adp_stub"] + }] } # Insert the slave template template::tag slave { params } { - #Start developer support frame around subordinate template. - if { [namespace which ::ds_enabled_p] ne "" - && [namespace which ::ds_adp_start_box] ne "" } { + #Start developer support frame around subordinate template. + if { [namespace which ::ds_enabled_p] ne "" + && [namespace which ::ds_adp_start_box] ne "" } { - ::ds_adp_start_box - } + ::ds_adp_start_box + } - template::adp_append_code { - if { [info exists __adp_slave] } { - append __adp_output $__adp_slave - } - } + template::adp_append_code { + if { [info exists __adp_slave] } { + append __adp_output $__adp_slave + } + } - #End developer support frame around subordinate template. - if { [namespace which ::ds_enabled_p] ne "" - && [namespace which ::ds_adp_end_box] ne "" } { + #End developer support frame around subordinate template. + if { [namespace which ::ds_enabled_p] ne "" + && [namespace which ::ds_adp_end_box] ne "" } { - ::ds_adp_end_box - } + ::ds_adp_end_box + } } @@ -247,47 +247,47 @@ template::tag multiple { chunk params } { - set name [template::get_attribute multiple $params name ] - set startrow [template::get_attribute multiple $params startrow 0] - set maxrows [template::get_attribute multiple $params maxrows -1]; #unlimit - set delimiter [template::get_attribute multiple $params delimiter ""] + set name [template::get_attribute multiple $params name ] + set startrow [template::get_attribute multiple $params startrow 0] + set maxrows [template::get_attribute multiple $params maxrows -1]; #unlimit + set delimiter [template::get_attribute multiple $params delimiter ""] - set tag_id [template::current_tag] + set tag_id [template::current_tag] - set i "__${tag_id}_i" + set i "__${tag_id}_i" - template::adp_append_code " + template::adp_append_code " if {\[info exists $name\]} { upvar 0 $name __${tag_id}_swap } for { set $i [expr {1 + $startrow}] } { \$$i <= \${$name:rowcount}" - if {$maxrows >= 0} { - template::adp_append_code " && \$$i <= $maxrows + $startrow" \ - -nobreak - } + if {$maxrows >= 0} { + template::adp_append_code " && \$$i <= $maxrows + $startrow" \ + -nobreak + } - template::adp_append_code " } { incr $i } { + template::adp_append_code " } { incr $i } { upvar 0 $name:\$$i $name " -nobreak - template::adp_compile_chunk $chunk + template::adp_compile_chunk $chunk - if { $delimiter ne "" } { - template::adp_append_code " if { \$$i < \${$name:rowcount}" + if { $delimiter ne "" } { + template::adp_append_code " if { \$$i < \${$name:rowcount}" - if {$maxrows >= 0} { - template::adp_append_code " && \$$i < $maxrows + $startrow" \ - -nobreak - } + if {$maxrows >= 0} { + template::adp_append_code " && \$$i < $maxrows + $startrow" \ + -nobreak + } - template::adp_append_code " } {\n" - template::adp_append_string $delimiter - template::adp_append_code "\n}\n" - } + template::adp_append_code " } {\n" + template::adp_append_string $delimiter + template::adp_append_code "\n}\n" + } - template::adp_append_code "} + template::adp_append_code "} if {\[info exists __${tag_id}_swap\]} { upvar 0 __${tag_id}_swap $name @@ -298,83 +298,83 @@ template::tag list { chunk params } { - # the list tag accepts a value so that it may be used without a data - # source in the Tcl script + # the list tag accepts a value so that it may be used without a data + # source in the Tcl script - set value [ns_set iget $params value] + set value [ns_set iget $params value] - # If the value exists, use it and create a fake name for it + # If the value exists, use it and create a fake name for it - if { ![template::util::is_nil value] } { + if { ![template::util::is_nil value] } { - set name [ns_set iget $params name] - if { $name eq "" } { - set name "__ats_list_value" - } + set name [ns_set iget $params name] + if { $name eq "" } { + set name "__ats_list_value" + } - template::adp_append_code [list set $name $value] - template::adp_append_code "set $name:rowcount \[llength \$$name\]\n" + template::adp_append_code [list set $name $value] + template::adp_append_code "set $name:rowcount \[llength \$$name\]\n" - } else { + } else { - # Expect a data source from the Tcl script - set name [template::get_attribute list $params name] - template::adp_append_code "\nset {$name:rowcount} \[llength \${$name}\]\n" - } + # Expect a data source from the Tcl script + set name [template::get_attribute list $params name] + template::adp_append_code "\nset {$name:rowcount} \[llength \${$name}\]\n" + } - template::adp_append_code " + template::adp_append_code " for { set __ats_${name}_i 0 } { \$__ats_${name}_i < \${$name:rowcount} } { incr __ats_${name}_i } { set $name:item \[lindex \${$name} \$__ats_${name}_i\] set $name:rownum \[expr {\$__ats_${name}_i + 1}\] " - template::adp_compile_chunk $chunk + template::adp_compile_chunk $chunk - template::adp_append_code "}" + template::adp_append_code "}" } # Create a recursed group, generating a recursive multirow block until the # column name stays the same template::tag group { chunk params } { - set column [template::get_attribute group $params column] - set delimiter [template::get_attribute group $params delimiter ""] + set column [template::get_attribute group $params column] + set delimiter [template::get_attribute group $params delimiter ""] - # Scan the parameter stack backward, looking for the tag name + # Scan the parameter stack backward, looking for the tag name - set multiple_tag_id [template::enclosing_tag multiple] + set multiple_tag_id [template::enclosing_tag multiple] - if {$multiple_tag_id eq {}} { - error "No enclosing MULTIPLE tag for GROUP tag on column $column" - } + if {$multiple_tag_id eq {}} { + error "No enclosing MULTIPLE tag for GROUP tag on column $column" + } - # Get the name of the multiple variable we're looping over - set name [template::tag_attribute $multiple_tag_id name] + # Get the name of the multiple variable we're looping over + set name [template::tag_attribute $multiple_tag_id name] - set tag_id [template::current_tag] + set tag_id [template::current_tag] - # If we're inside another group tag, we'll need to save and restore that tag's groupnum and groupnum_last_p values - # Find enclosing group tag, if one exists - set group_tag_id [template::enclosing_tag group] + # If we're inside another group tag, we'll need to save and restore that tag's groupnum and groupnum_last_p values + # Find enclosing group tag, if one exists + set group_tag_id [template::enclosing_tag group] - # Save groupnum pseudocolumns from surrounding group tag - # We don't care about saving groupnum_last_p, since this doesn't work - # for group tags that have other group tags inside them, since we can't know - # if we're the last row until the inner group tag has eaten up all the - # rows between the start of this tag and the end. - if { $group_tag_id ne "" } { - template::adp_append_code " + # Save groupnum pseudocolumns from surrounding group tag + # We don't care about saving groupnum_last_p, since this doesn't work + # for group tags that have other group tags inside them, since we can't know + # if we're the last row until the inner group tag has eaten up all the + # rows between the start of this tag and the end. + if { $group_tag_id ne "" } { + template::adp_append_code " if { \[info exists ${name}(groupnum)\] } { set __${tag_id}_${group_tag_id}_groupnum \$${name}(groupnum) } " - } + } - set i "__${multiple_tag_id}_i" + set i "__${multiple_tag_id}_i" - # while the value of name(column) stays the same - template::adp_append_code " + # while the value of name(column) stays the same + template::adp_append_code " set __${tag_id}_group_rowcount 1 while { 1 } { set ${name}(groupnum) \$__${tag_id}_group_rowcount @@ -386,79 +386,79 @@ } " - template::adp_compile_chunk $chunk + template::adp_compile_chunk $chunk - # look ahead to the next value and break if it is different - # otherwise advance the cursor to the next row - template::adp_append_code [subst -nocommands { - if { \$$i >= \${$name:rowcount} } { - break - } - upvar 0 ${name}:[expr {\$$i + 1}] $name:next - if { \${${name}:next($column)} ne \$${name}(${column}) } { - break - } - }] + # look ahead to the next value and break if it is different + # otherwise advance the cursor to the next row + template::adp_append_code [subst -nocommands { + if { \$$i >= \${$name:rowcount} } { + break + } + upvar 0 ${name}:[expr {\$$i + 1}] $name:next + if { \${${name}:next($column)} ne \$${name}(${column}) } { + break + } + }] - if { $delimiter ne "" } { - template::adp_append_string $delimiter - } + if { $delimiter ne "" } { + template::adp_append_string $delimiter + } - template::adp_append_code " + template::adp_append_code " incr $i upvar 0 $name:\$$i $name incr __${tag_id}_group_rowcount } " - # Restore saved groupnum pseudocolumns - if { $group_tag_id ne "" } { - set varName __${tag_id}_${group_tag_id}_groupnum - template::adp_append_code [subst -nocommands { - if { [info exists $varName] } { - set ${name}(groupnum) \$$varName - } - }] - } + # Restore saved groupnum pseudocolumns + if { $group_tag_id ne "" } { + set varName __${tag_id}_${group_tag_id}_groupnum + template::adp_append_code [subst -nocommands { + if { [info exists $varName] } { + set ${name}(groupnum) \$$varName + } + }] + } } # Repeat a template chunk consisting of a grid cell for each row of a # multirow data source template::tag grid { chunk params } { - set name [template::get_attribute grid $params name] - # cols must be a float for ceil to work - set cols [template::get_attribute grid $params cols] - # Horizontal or vertical ? - set orientation [template::get_attribute grid $params orientation vertical] + set name [template::get_attribute grid $params name] + # cols must be a float for ceil to work + set cols [template::get_attribute grid $params cols] + # Horizontal or vertical ? + set orientation [template::get_attribute grid $params orientation vertical] - template::adp_append_code " + template::adp_append_code " set rows \[expr {ceil(\${$name:rowcount} / $cols.0)}\] for { set __r 1 } { \$__r <= \$rows } { incr __r } { for { set __c 1 } { \$__c <= $cols } { incr __c } { " - if {$orientation eq "vertical"} { - template::adp_append_code " + if {$orientation eq "vertical"} { + template::adp_append_code " set rownum \[expr {1 + int((\$__r - 1) + ((\$__c - 1) * \$rows))}\] " - } else { - template::adp_append_code " + } else { + template::adp_append_code " set rownum \[expr {1 + int((\$__c - 1) + ((\$__r - 1) * $cols))}\] " - } + } - template::adp_append_code " + template::adp_append_code " upvar 0 $name:\$rownum $name set ${name}(rownum) \$rownum set ${name}(row) \$__r set ${name}(col) \$__c " - template::adp_compile_chunk $chunk + template::adp_compile_chunk $chunk - template::adp_append_code " + template::adp_append_code " } }" } @@ -478,106 +478,106 @@ template::tag else { chunk params } { - template::adp_append_code "else {" -nobreak + template::adp_append_code "else {" -nobreak - template::adp_compile_chunk $chunk + template::adp_compile_chunk $chunk - template::adp_append_code "}" + template::adp_append_code "}" } # Output a template chunk without parsing, for preprocessed templates template::tag noparse { chunk params } { - # escape quotes - regsub -all -- {[\]\[""\\$]} $chunk {\\&} quoted + # escape quotes + regsub -all -- {[\]\[""\\$]} $chunk {\\&} quoted - template::adp_append_string $quoted + template::adp_append_string $quoted } # Render the HTML for the form widget, incorporating any additional # markup attributes specified in the template. template::tag formwidget { params } { - set id [template::get_attribute formwidget $params id] + set id [template::get_attribute formwidget $params id] - # get any additional HTML attributes specified by the designer - set tag_attributes [template::util::set_to_list $params id] + # get any additional HTML attributes specified by the designer + set tag_attributes [template::util::set_to_list $params id] - template::adp_append_string \ - "\[template::element render \${form:id} [list $id] { $tag_attributes } \]" + template::adp_append_string \ + "\[template::element render \${form:id} [list $id] { $tag_attributes } \]" } # Display the help information for an element template::tag formhelp { params } { - set id [template::get_attribute formhelp $params id] + set id [template::get_attribute formhelp $params id] - # get any additional HTML attributes specified by the designer - set tag_attributes [template::util::set_to_list $params id] + # get any additional HTML attributes specified by the designer + set tag_attributes [template::util::set_to_list $params id] - template::adp_append_string \ - "\[template::element render_help \${form:id} [list $id] { $tag_attributes } \]" + template::adp_append_string \ + "\[template::element render_help \${form:id} [list $id] { $tag_attributes } \]" } # Report a form error if one is specified. template::tag formerror { chunk params } { - set id [template::get_attribute formerror $params id] - set type [ns_set get $params type] + set id [template::get_attribute formerror $params id] + set type [ns_set get $params type] - if {$type eq {}} { - set key $id - } else { - set key $id:$type - } + if {$type eq {}} { + set key $id + } else { + set key $id:$type + } - template::adp_append_code " + template::adp_append_code " if \{ \[info exists formerror($key)\] \} \{ set formerror($id) \$formerror($key) " - if {$chunk eq {}} { + if {$chunk eq {}} { - template::adp_append_string "\$formerror($key)" + template::adp_append_string "\$formerror($key)" - } else { + } else { - template::adp_compile_chunk $chunk - } + template::adp_compile_chunk $chunk + } - template::adp_append_code "\}" + template::adp_append_code "\}" } # Render a group of form widgets template::tag formgroup { chunk params } { - set id [template::get_attribute formgroup $params id] + set id [template::get_attribute formgroup $params id] - # get any additional HTML attributes specified by the designer - set tag_attributes [template::util::set_to_list $params id] + # get any additional HTML attributes specified by the designer + set tag_attributes [template::util::set_to_list $params id] - # generate a list of options and option labels as a data source + # generate a list of options and option labels as a data source - template::adp_append_code \ - "template::element options \${form:id} [list $id] { $tag_attributes }" + template::adp_append_code \ + "template::element options \${form:id} [list $id] { $tag_attributes }" - # make sure name is a parameter to pass to the rendering tag handler - ns_set update $params name formgroup - ns_set update $params id formgroup + # make sure name is a parameter to pass to the rendering tag handler + ns_set update $params name formgroup + ns_set update $params id formgroup - # Use the multiple or grid tag to render the form group depending on - # whether the cols attribute was specified + # Use the multiple or grid tag to render the form group depending on + # whether the cols attribute was specified - if { [ns_set find $params cols] == -1 } { - template_tag_multiple $chunk $params - } else { - template_tag_grid $chunk $params - } + if { [ns_set find $params cols] == -1 } { + template_tag_multiple $chunk $params + } else { + template_tag_grid $chunk $params + } } # render one element from a formgroup @@ -606,51 +606,51 @@ template::tag formtemplate { chunk params } { - set level [template::adp_level] - set id [template::get_attribute formtemplate $params id] + set level [template::adp_level] + set id [template::get_attribute formtemplate $params id] - upvar #$level $id:properties form_properties + upvar #$level $id:properties form_properties - template::adp_append_code [list set form:id $id] + template::adp_append_code [list set form:id $id] - # Set optional attributes for the grid template - template::adp_append_code \ - [list upvar 0 $id:properties form_properties] + # Set optional attributes for the grid template + template::adp_append_code \ + [list upvar 0 $id:properties form_properties] - foreach varname {headers title cols} { + foreach varname {headers title cols} { - set form_properties($varname) [ns_set iget $params $varname] - template::adp_append_code \ - [list set form_properties($varname) $form_properties($varname)] - } + set form_properties($varname) [ns_set iget $params $varname] + template::adp_append_code \ + [list set form_properties($varname) $form_properties($varname)] + } - # get any additional HTML attributes specified by the designer - set tag_attributes [template::util::set_to_list $params \ - id style method title cols headers] + # get any additional HTML attributes specified by the designer + set tag_attributes [template::util::set_to_list $params \ + id style method title cols headers] - template::adp_append_string \ - [subst -nocommands {[template::form render $id { $tag_attributes } ]}] + template::adp_append_string \ + [subst -nocommands {[template::form render $id { $tag_attributes } ]}] - if {[string trim $chunk] eq {}} { + if {[string trim $chunk] eq {}} { - # generate the form body dynamically if none specified. - set style [ns_set iget $params style] - template::adp_append_string "\[template::form generate $id $style\]" + # generate the form body dynamically if none specified. + set style [ns_set iget $params style] + template::adp_append_string "\[template::form generate $id $style\]" - } else { + } else { - # compile the static form layout specified in the template - template::adp_compile_chunk $chunk + # compile the static form layout specified in the template + template::adp_compile_chunk $chunk - # Render any hidden variables that have not been rendered yet - template::adp_append_string \ - [subst -nocommands {[template::form check_elements $id]}] - } + # Render any hidden variables that have not been rendered yet + template::adp_append_string \ + [subst -nocommands {[template::form check_elements $id]}] + } - if { [info exists form_properties(fieldset)] } { - template::adp_append_string "" - } - template::adp_append_string "" + if { [info exists form_properties(fieldset)] } { + template::adp_append_string "" + } + template::adp_append_string "" } @@ -666,7 +666,7 @@ # @param params The ns_set id for extra HTML parameters template::tag child { params } { - publish::process_tag child $params + publish::process_tag child $params } # @private tag_relation @@ -681,7 +681,7 @@ # @param params The ns_set id for extra HTML parameters template::tag relation { params } { - publish::process_tag relation $params + publish::process_tag relation $params } @@ -698,22 +698,22 @@ template::tag content { params } { - # Get item id/revision_id - set item_id [publish::get_main_item_id] - set revision_id [publish::get_main_revision_id] + # Get item id/revision_id + set item_id [publish::get_main_item_id] + set revision_id [publish::get_main_revision_id] - # Concatenate all other keys into the extra arguments list - set extra_args [publish::set_to_pairs $params] + # Concatenate all other keys into the extra arguments list + set extra_args [publish::set_to_pairs $params] - # Add code to flush the cache + # Add code to flush the cache - # Render the item, return the html - set command "publish::get_html_body \[publish::handle_item" - append command " \$::content::item_id" - append command " -html \{$extra_args\} -no_merge -embed" - append command " -revision_id \[publish::get_main_revision_id\]\]" + # Render the item, return the html + set command "publish::get_html_body \[publish::handle_item" + append command " \$::content::item_id" + append command " -html \{$extra_args\} -no_merge -embed" + append command " -revision_id \[publish::get_main_revision_id\]\]" - template::adp_append_code "append __adp_output \[$command\]" + template::adp_append_code "append __adp_output \[$command\]" } # Include another template in the current template, but make @@ -728,48 +728,48 @@ template::tag include-optional { chunk params } { - # - # Check, if the src can be resolved against resources/templates in - # the theme package - # - set src [template::themed_template [ns_set iget $params src]] - set ds [ns_set iget $params ds] - if {$ds eq ""} {set ds 1} + # + # Check, if the src can be resolved against resources/templates in + # the theme package + # + set src [template::themed_template [ns_set iget $params src]] + set ds [ns_set iget $params ds] + if {$ds eq ""} {set ds 1} - #Start developer support frame around subordinate template. - if { $ds && [namespace which ::ds_enabled_p] ne "" - && [namespace which ::ds_adp_start_box] ne ""} { + #Start developer support frame around subordinate template. + if { $ds && [namespace which ::ds_enabled_p] ne "" + && [namespace which ::ds_adp_start_box] ne ""} { - ::ds_adp_start_box -stub "\[template::util::url_to_file \"$src\" \"\$__adp_stub\"\]" - } + ::ds_adp_start_box -stub "\[template::util::url_to_file \"$src\" \"\$__adp_stub\"\]" + } - set command [template::template_tag_include_command $src $params] + set command [template::template_tag_include_command $src $params] - # __adp_include_optional_output is a list that operates like a stack - # So first we execute the include template, and push the result onto this stack - # Then, if the output contained anything but whitespace, we also output the - # chunk inside the include-optional tag. - # Finally, we pop the output off of the __adp_include_optional_output stack. + # __adp_include_optional_output is a list that operates like a stack + # So first we execute the include template, and push the result onto this stack + # Then, if the output contained anything but whitespace, we also output the + # chunk inside the include-optional tag. + # Finally, we pop the output off of the __adp_include_optional_output stack. - template::adp_append_code "ad_try { lappend __adp_include_optional_output \[$command\] } on error {errmsg} {" - template::adp_append_code " append __adp_output \"Error in include template \\\"\[template::util::url_to_file \"$src\" \"\$__adp_stub\"\]\\\": \[ns_quotehtml \$errmsg\]\"" - template::adp_append_code " ad_log Error \"Error in include template \\\"\[template::util::url_to_file \"$src\" \"\$__adp_stub\"\]\\\": \$errmsg\"" - template::adp_append_code "} on ok {r} {" - template::adp_append_code "if { \[string trim \[lindex \$__adp_include_optional_output end\]\] ne {} } {" + template::adp_append_code "ad_try { lappend __adp_include_optional_output \[$command\] } on error {errmsg} {" + template::adp_append_code " append __adp_output \"Error in include template \\\"\[template::util::url_to_file \"$src\" \"\$__adp_stub\"\]\\\": \[ns_quotehtml \$errmsg\]\"" + template::adp_append_code " ad_log Error \"Error in include template \\\"\[template::util::url_to_file \"$src\" \"\$__adp_stub\"\]\\\": \$errmsg\"" + template::adp_append_code "} on ok {r} {" + template::adp_append_code "if { \[string trim \[lindex \$__adp_include_optional_output end\]\] ne {} } {" - template::adp_compile_chunk $chunk - template::adp_append_code " + template::adp_compile_chunk $chunk + template::adp_append_code " } template::util::lpop __adp_include_optional_output } " - #End developer support frame around subordinate template. - if { $ds && [namespace which ::ds_enabled_p] ne "" - && [namespace which ::ds_adp_end_box] ne "" } { - ::ds_adp_end_box -stub [ - subst -nocommands {[template::util::url_to_file "$src" "\$__adp_stub"]}] - } + #End developer support frame around subordinate template. + if { $ds && [namespace which ::ds_enabled_p] ne "" + && [namespace which ::ds_adp_end_box] ne "" } { + ::ds_adp_end_box -stub [ + subst -nocommands {[template::util::url_to_file "$src" "\$__adp_stub"]}] + } } @@ -786,50 +786,50 @@ } template::tag trn { chunk params } { - # DRB: we have to do our own variable substitution as the template framework doesn't handle - # it for us ... being able to use page variables here is consistent with the rest - # of the templating engine. + # DRB: we have to do our own variable substitution as the template framework doesn't handle + # it for us ... being able to use page variables here is consistent with the rest + # of the templating engine. - # LARS: Note that this version of the tag requires a body, like this: - # default. - # This is the way to give a default value, and is okay, because we now have the #...# - # notation for when there's no default value. - # Will register the key in the message catalog if it doesn't exist. + # LARS: Note that this version of the tag requires a body, like this: + # default. + # This is the way to give a default value, and is okay, because we now have the #...# + # notation for when there's no default value. + # Will register the key in the message catalog if it doesn't exist. - set size [ns_set size $params] - for { set i 0 } { $i < $size } { incr i } { - set [ns_set key $params $i] [ns_set value $params $i] - # substitute array variables - regsub {@([a-zA-Z0-9_]+)\.([a-zA-Z0-9_.]+)@} [set [ns_set key $params $i]] {${\1(\2)}} [ns_set key $params $i] - # substitute regular variables - regsub {@([a-zA-Z0-9_:]+)@} [set [ns_set key $params $i]] {${\1}} [ns_set key $params $i] - } + set size [ns_set size $params] + for { set i 0 } { $i < $size } { incr i } { + set [ns_set key $params $i] [ns_set value $params $i] + # substitute array variables + regsub {@([a-zA-Z0-9_]+)\.([a-zA-Z0-9_.]+)@} [set [ns_set key $params $i]] {${\1(\2)}} [ns_set key $params $i] + # substitute regular variables + regsub {@([a-zA-Z0-9_:]+)@} [set [ns_set key $params $i]] {${\1}} [ns_set key $params $i] + } - # And this needs to be executed at page execution time due to interactions with the - # preferences changing code. This is consistent with what the way #notation# is handled - # (the ad_conn call is dumped into the code, not executed on the spot) + # And this needs to be executed at page execution time due to interactions with the + # preferences changing code. This is consistent with what the way #notation# is handled + # (the ad_conn call is dumped into the code, not executed on the spot) - if { ![info exists locale] } { - # We need this to be executed at template execution time, because the template's - # compiled code will be cached and reused for many requests. - set locale "\[ad_conn locale\]" - } else { - # Check to see if we should register this into the message catalog - if { [string length $locale] == 2 } { - set locale [lang::util::default_locale_from_lang $locale] - } + if { ![info exists locale] } { + # We need this to be executed at template execution time, because the template's + # compiled code will be cached and reused for many requests. + set locale "\[ad_conn locale\]" + } else { + # Check to see if we should register this into the message catalog + if { [string length $locale] == 2 } { + set locale [lang::util::default_locale_from_lang $locale] + } - # Check the cache - if { ![lang::message::message_exists_p $locale $key] } { - lang::message::register $locale $key $chunk - } - } + # Check the cache + if { ![lang::message::message_exists_p $locale $key] } { + lang::message::register $locale $key $chunk + } + } - # quote dollar signs, square bracket and quotes - regsub -all -- {[\]\[""\\$]} $chunk {\\&} quoted_chunk + # quote dollar signs, square bracket and quotes + regsub -all -- {[\]\[""\\$]} $chunk {\\&} quoted_chunk - template::adp_append_code \ - [subst -nocommands {append __adp_output [_ $locale $key $quoted_chunk]}] + template::adp_append_code \ + [subst -nocommands {append __adp_output [_ $locale $key $quoted_chunk]}] }