MCPcopy
hub / github.com/django/django / resolve

Method resolve

django/template/base.py:802–837  ·  view source on GitHub ↗
(self, context, ignore_failures=False)

Source from the content-addressed store, hash-verified

800 self.is_var = isinstance(var_obj, Variable)
801
802 def resolve(self, context, ignore_failures=False):
803 if self.is_var:
804 try:
805 obj = self.var.resolve(context)
806 except VariableDoesNotExist:
807 if ignore_failures:
808 obj = None
809 else:
810 string_if_invalid = context.template.engine.string_if_invalid
811 if string_if_invalid:
812 if "%s" in string_if_invalid:
813 return string_if_invalid % self.var
814 else:
815 return string_if_invalid
816 else:
817 obj = string_if_invalid
818 else:
819 obj = self.var
820 for func, args in self.filters:
821 arg_vals = []
822 for lookup, arg in args:
823 if not lookup:
824 arg_vals.append(mark_safe(arg))
825 else:
826 arg_vals.append(arg.resolve(context))
827 if getattr(func, "expects_localtime", False):
828 obj = template_localtime(obj, context.use_tz)
829 if getattr(func, "needs_autoescape", False):
830 new_obj = func(obj, autoescape=context.autoescape, *arg_vals)
831 else:
832 new_obj = func(obj, *arg_vals)
833 if getattr(func, "is_safe", False) and isinstance(obj, SafeData):
834 obj = mark_safe(new_obj)
835 else:
836 obj = new_obj
837 return obj
838
839 def args_check(name, func, provided):
840 provided = list(provided)

Callers

nothing calls this directly

Calls 4

mark_safeFunction · 0.90
template_localtimeFunction · 0.90
resolveMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected