- return node.getParent() != null ? new JcrModel(node.getParent()) : null;
-
- Property property = node.getProperty(key);
- if (property == null)
- return null;
- return new SimpleScalar(property.getString());
+ return !"/".equals(node.getPath()) ? new JcrModel(node.getParent()) : null;
+
+ Property property;
+ if (!node.hasProperty(key)) {
+ List<Property> props = new ArrayList<>();
+ PropertyIterator pit = node.getProperties("*:" + key);
+ while (pit.hasNext())
+ props.add(pit.nextProperty());
+ if (props.size() == 0)
+ return null;
+ if (props.size() > 1)
+ throw new TemplateModelException(
+ "Too many properties match " + key + " (" + props + "), use prefix with \\: escape");
+ property = props.get(0);
+ } else
+ property = node.getProperty(key);
+ return propertyValues(property);