+ def resolve_expects(var):
+ if not hasattr(var, 'hash_dirty'):
+ var.hash_dirty = False
+
+ for i, arg in enumerate(var.args):
+ if isinstance(arg, SsiExpect):
+ var.args[i] = resolved[arg.name]
+ var.hash_dirty = True
+ for k, arg in var.kwargs.items():
+ if isinstance(arg, SsiExpect):
+ var.kwargs[k] = resolved[arg.name]
+ var.hash_dirty = True
+
+ for arg in var.args + list(var.kwargs.values()):
+ if isinstance(arg, SsiVariable):
+ var.hash_dirty = resolve_expects(arg) or var.hash_dirty
+
+ hash_dirty = var.hash_dirty
+ if var.hash_dirty:
+ # Rehash after calculating the SsiExpects with real
+ # values, because that's what the included views expect.
+ var.rehash()
+ var.hash_dirty = False
+
+ return hash_dirty
+
+ def resolve_args(var):
+ kwargs = {}
+ for k, arg in var.kwargs.items():
+ kwargs[k] = resolved[arg.name] if isinstance(arg, SsiVariable) else arg
+ new_var = SsiVariable(var.tagpath,
+ [resolved[arg.name] if isinstance(arg, SsiVariable) else arg for arg in var.args],
+ kwargs)
+ return new_var
+