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

Method resolve

django/template/base.py:940–956  ·  view source on GitHub ↗

Resolve this variable against a given context.

(self, context)

Source from the content-addressed store, hash-verified

938 self.lookups = tuple(var.split(VARIABLE_ATTRIBUTE_SEPARATOR))
939
940 def resolve(self, context):
941 """Resolve this variable against a given context."""
942 if self.lookups is not None:
943 # We're dealing with a variable that needs to be resolved
944 value = self._resolve_lookup(context)
945 else:
946 # We're dealing with a literal, so it's already been "resolved"
947 value = self.literal
948 if self.translate:
949 is_safe = isinstance(value, SafeData)
950 msgid = value.replace("%", "%%")
951 msgid = mark_safe(msgid) if is_safe else msgid
952 if self.message_context:
953 return pgettext_lazy(self.message_context, msgid)
954 else:
955 return gettext_lazy(msgid)
956 return value
957
958 def __repr__(self):
959 return "<%s: %r>" % (self.__class__.__name__, self.var)

Callers 15

renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
urlMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45

Calls 2

_resolve_lookupMethod · 0.95
mark_safeFunction · 0.90

Tested by 15

get_label_moduleFunction · 0.36
setUpClassMethod · 0.36
build_geoip_pathFunction · 0.36
test_no_database_fileMethod · 0.36
assertFileFoundMethod · 0.36
assertFileNotFoundMethod · 0.36
setUpMethod · 0.36
setUpMethod · 0.36