[interchange] Allow passing params to error tag, which are replaced (same functionality as [warnings]). Useful for

Josh Lavin interchange-cvs at icdevgroup.org
Wed Jul 3 20:46:28 UTC 2013


commit bd39e2c6ceea6f1d2f97cee4283406777544f616
Author: Josh Lavin <josh at perusion.com>
Date:   Wed Jul 3 13:44:00 2013 -0700

    Allow passing params to error tag, which are replaced (same functionality as [warnings]). Useful for localization.
    
    Example:
    	[error
    		name=username
    		set="That was a bad username. Please contact us at %s or %s."
    		param.0="(800) 555-1212"
    		param.1="(512) 555-1212"
    	]

 code/SystemTag/error.coretag |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/code/SystemTag/error.coretag b/code/SystemTag/error.coretag
index 18e4adb..c120470 100644
--- a/code/SystemTag/error.coretag
+++ b/code/SystemTag/error.coretag
@@ -37,6 +37,10 @@ sub tag_error {
 	if($opt->{set}) {
 		$opt->{keep} = 1 unless defined $opt->{keep};
 		my $error = delete $opt->{set};
+		if($opt->{param}) {
+			$opt->{param} = [ $opt->{param} ] unless ref($opt->{param} );
+			$error = sprintf($error, @{$opt->{param}});
+		}
 		return set_error($error, $var, $opt);
 	}
 	my $err_ref = $Vend::Session->{errors};



More information about the interchange-cvs mailing list