コード例 #1
0
 /**
  * Creates a child context.
  *
  * @param parent The parent context. Required.
  * @param model The target value. Resolved as '.' or 'this' inside templates. Required.
  * @return A child context.
  */
 private static Context child(final Context parent, final Object model) {
   checkNotNull(parent, "A parent context is required.");
   Context child = new Context(model);
   child.extendedContext = new Context(new HashMap<String, Object>());
   child.parent = parent;
   child.storage = parent.storage;
   return child;
 }
コード例 #2
0
 /**
  * Creates a root context.
  *
  * @param model The target value. Resolved as '.' or 'this' inside templates. Required.
  * @return A root context.
  */
 private static Context root(final Object model) {
   Context root = new Context(model);
   root.extendedContext = new Context(new HashMap<String, Object>());
   root.parent = null;
   root.storage = new HashMap<String, Object>();
   root.storage.put(PARTIALS, new HashMap<String, Template>());
   return root;
 }