changeset 6180:e30d396defa5

Datacage: Added function dc:get('var-name'). Returns content of variable var-name or NULL if not defined. This works around resolving unknown variables.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 04 Jun 2013 15:17:19 +0200
parents 5297e173c272
children 65f278bd4ef5
files artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FunctionResolver.java
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FunctionResolver.java	Tue Jun 04 13:28:31 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FunctionResolver.java	Tue Jun 04 15:17:19 2013 +0200
@@ -139,6 +139,18 @@
                 return FunctionResolver.this.buildHelper.frames.dump();
             }
         });
+
+        addFunction("get", 1, new XPathFunction() {
+            @Override
+            public Object evaluate(List args) throws XPathFunctionException {
+                Object o = args.get(0);
+                if (o instanceof String) {
+                    FunctionResolver.this.buildHelper.frames.getNull(
+                        (String)o, StackFrames.NULL);
+                }
+                return StackFrames.NULL;
+            }
+        });
     }
 
     /**

http://dive4elements.wald.intevation.org