Index: openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl,v diff -u -r1.42 -r1.42.2.1 --- openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl 26 Feb 2004 15:28:46 -0000 1.42 +++ openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl 18 Mar 2004 09:07:46 -0000 1.42.2.1 @@ -626,7 +626,7 @@ @author Peter Marklund (peter@collaboraid.biz) @creation-date 12 November 2002 } { - return {^(.*?)(%%|%[-a-zA-Z0-9_:\.]+%)(.*)$} + return {^(.*?)(%%|%[-a-zA-Z0-9_:\.]+(?:;noquote)?%)(.*)$} } ad_proc -public lang::message::message_exists_p { locale key } { Index: openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl,v diff -u -r1.32 -r1.32.2.1 --- openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl 12 Mar 2004 13:45:04 -0000 1.32 +++ openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl 18 Mar 2004 09:07:46 -0000 1.32.2.1 @@ -445,20 +445,40 @@ Convert ADP variables to percentage_signs - the notation used to interpolate variable values into acs-lang messages. -

- We don't currently support having noquote vars in messages (i.e. we don't - substitute @var_name;noquote@). -

- @author Peter Marklund } { # substitute array variable references # loop to handle the case of adjacent variable references, like @a@@b@ while {[regsub -all [template::adp_array_variable_regexp] $text {\1%\2.\3%} text]} {} + while {[regsub -all [template::adp_array_variable_regexp_noquote] $text {\1%\2.\3;noquote%} text]} {} # substitute simple variable references while {[regsub -all [template::adp_variable_regexp] $text {\1%\2%} text]} {} + while {[regsub -all [template::adp_variable_regexp_noquote] $text {\1%\2;noquote%} text]} {} + return $text +} + +ad_proc -private lang::util::convert_percentage_signs_to_adp_variables { text } { + Convert percentage_signs message vars to adp var syntax. + + @see lang::util::convert_adp_variables_to_percentage_signs + + @author Peter Marklund +} { + # substitute array variable references + # loop to handle the case of adjacent variable references, like @a@@b@ + regsub -all {@} [template::adp_array_variable_regexp] {%} pattern + while {[regsub -all $pattern $text {\1@\2.\3@} text]} {} + regsub -all {@} [template::adp_array_variable_regexp_noquote] {%} pattern + while {[regsub -all $pattern $text {\1@\2.\3;noquote@} text]} {} + + # substitute simple variable references + regsub -all {@} [template::adp_variable_regexp] {%} pattern + while {[regsub -all $pattern $text {\1@\2@} text]} {} + regsub -all {@} [template::adp_variable_regexp_noquote] {%} pattern + while {[regsub -all $pattern $text {\1@\2;noquote@} text]} {} + return $text } Index: openacs-4/packages/acs-lang/tcl/test/acs-lang-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/test/acs-lang-test-procs.tcl,v diff -u -r1.15 -r1.15.2.1 --- openacs-4/packages/acs-lang/tcl/test/acs-lang-test-procs.tcl 12 Mar 2004 15:27:15 -0000 1.15 +++ openacs-4/packages/acs-lang/tcl/test/acs-lang-test-procs.tcl 18 Mar 2004 09:07:46 -0000 1.15.2.1 @@ -598,25 +598,31 @@ aa_register_case \ -procs { lang::util::convert_adp_variables_to_percentage_signs + lang::util::convert_percentage_signs_to_adp_variables } util__convert_adp_variables_to_percentage_signs { @author Peter Marklund (peter@collaboraid.biz) @creation-date 25 October 2002 } { - set adp_chunk "@array.variable_name@ @variable_name2@ peter@collaboraid.biz" - + set adp_chunk "@array.variable_name@ @variable_name2;noquote@ peter@collaboraid.biz" set adp_chunk_converted [lang::util::convert_adp_variables_to_percentage_signs $adp_chunk] - set adp_chunk_expected "%array.variable_name% %variable_name2% peter@collaboraid.biz" + set adp_chunk_expected "%array.variable_name% %variable_name2;noquote% peter@collaboraid.biz" + aa_equals "adp vars should be subsituted with percentage sings" $adp_chunk_converted $adp_chunk_expected + set adp_chunk_converted_back [lang::util::convert_percentage_signs_to_adp_variables $adp_chunk_converted] + aa_equals "after having converted the text with percentage signs back to adp we should have what we started with" $adp_chunk_converted $adp_chunk_expected - aa_true "adp vars should be subsituted with percentage sings" [string equal $adp_chunk_converted \ - $adp_chunk_expected] - # Test that a string can start with adp vars - set adp_chunk "@first_names@ @last_name@ peter@collaboraid.biz" + set adp_chunk "@first_names.foobar;noquote@ @last_name@ peter@collaboraid.biz" set adp_chunk_converted [lang::util::convert_adp_variables_to_percentage_signs $adp_chunk] - set adp_chunk_expected "%first_names% %last_name% peter@collaboraid.biz" - aa_true "adp vars should be subsituted with percentage sings" [string equal $adp_chunk_converted \ - $adp_chunk_expected] + set adp_chunk_expected "%first_names.foobar;noquote% %last_name% peter@collaboraid.biz" + aa_equals "adp vars should be subsituted with percentage sings" $adp_chunk_converted $adp_chunk_expected + set adp_chunk_converted_back [lang::util::convert_percentage_signs_to_adp_variables $adp_chunk_converted] + aa_equals "after having converted the text with percentage signs back to adp we should have what we started with" $adp_chunk_converted $adp_chunk_expected + + set percentage_chunk {You are %role.character_title% (%role.role_pretty%)} + set percentage_chunk_converted [lang::util::convert_percentage_signs_to_adp_variables $percentage_chunk] + set percentage_chunk_expected {You are @role.character_title@ (@role.role_pretty@)} + aa_equals "converting percentage vars to adp vars" $percentage_chunk_converted $percentage_chunk_expected } aa_register_case \ 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.26 -r1.26.2.1 --- openacs-4/packages/acs-templating/tcl/parse-procs.tcl 27 Feb 2004 19:39:25 -0000 1.26 +++ openacs-4/packages/acs-templating/tcl/parse-procs.tcl 18 Mar 2004 09:07:44 -0000 1.26.2.1 @@ -357,11 +357,20 @@ set substitution "%" } else { # An embedded variable - + + # Remove any noquote instruction + set quote_p 1 + if { [regsub {;noquote} $percent_match {} substitution] } { + # We removed a noquote instruction so don't quote + set quote_p 0 + } + # Convert syntax to TCL syntax: # It's either an array variable or a tcl variable # array variables - regsub {^%([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)%$} $percent_match {$\1(\2)} substitution + # TODO: ad_quotehtml + # TODO: lang::util::localize + regsub {^%([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)%$} $substitution {$\1(\2)} substitution # ordinary variables regsub {^%([a-zA-Z0-9_:]+)%$} $substitution {$\1} substitution