Author: nbubna
Date: Wed Sep 1 18:28:11 2010
New Revision: 991637
URL: http://svn.apache.org/viewvc?rev=991637&view=rev
Log:
convenience method for silently setting scoped vars
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java?rev=991637&r1=991636&r2=991637&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
Wed Sep 1 18:28:11 2010
@@ -32,6 +32,7 @@ import java.util.Set;
*/
public class Scope extends AbstractMap
{
+ private static final String setReturnValue = "";
private Map storage;
private Object replaced;
private Scope parent;
@@ -85,6 +86,17 @@ public class Scope extends AbstractMap
}
/**
+ * Convenience method to call put(key,val) in a template
+ * without worrying about what is returned/rendered by the call.
+ * This should ALWAYS return an empty string.
+ */
+ public String set(Object key, Object value)
+ {
+ put(key, value);
+ return setReturnValue;
+ }
+
+ /**
* Allows #stop to easily trigger the proper StopCommand for this scope.
*/
protected void stop()