template::expand_percentage_signs (public)
template::expand_percentage_signs message
Defined in packages/acs-templating/tcl/parse-procs.tcl
Expand variables marked with percentage signs in caller's scope. Some examples - if example and array(variable) has the values Erik and Oluf in the caller's scope - the following expansion will occur: Here is an %example% variable. -> Here is an Erik variable. Here is an %array.variable% for you -> Here is an Oluf for you
- Parameters:
- message (required)
- Author:
- Christian Hvid
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- expand_percentage_signs
Source code: 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 if {$percent_match eq "%%"} { # A quoted percentage sign 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 # TODO: ns_quotehtml # TODO: lang::util::localize regsub -all -- {[\]\[\{\}\"]\\$} $substitution {\\&} substitution if { [regexp {^%([[:alnum:]_]+)\.([[:alnum:]_]+)%$} $substitution match arr key] } { # the array key name is substitured by the Tcl parser s regsub -all -- {[\]\[\{\}\"]\\$} $key {\\&} key set command "set ${arr}(${key})" set substitution [uplevel $command] } if { [regexp {^%([[:alnum:]_:]+)%$} $substitution match var] } { set command "set $var" set substitution [uplevel $command] } if {$quote_p} { set substitution [ns_quotehtml $substitution] } } append formatted_message $substitution } append formatted_message $remaining_message return $formatted_messageXQL Not present: Generic, PostgreSQL, Oracle