MCPcopy
hub / github.com/django/django / render_value_in_context

Function render_value_in_context

django/template/base.py:1139–1152  ·  view source on GitHub ↗

Convert any value to a string to become part of a rendered template. This means escaping, if required, and conversion to a string. If value is a string, it's expected to already be translated.

(value, context)

Source from the content-addressed store, hash-verified

1137
1138
1139def render_value_in_context(value, context):
1140 """
1141 Convert any value to a string to become part of a rendered template. This
1142 means escaping, if required, and conversion to a string. If value is a
1143 string, it's expected to already be translated.
1144 """
1145 value = template_localtime(value, use_tz=context.use_tz)
1146 value = localize(value, use_l10n=context.use_l10n)
1147 if context.autoescape:
1148 if not issubclass(type(value), str):
1149 value = str(value)
1150 return conditional_escape(value)
1151 else:
1152 return str(value)
1153
1154
1155class VariableNode(Node):

Callers 5

renderMethod · 0.90
render_valueMethod · 0.90
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85

Calls 3

template_localtimeFunction · 0.90
localizeFunction · 0.90
conditional_escapeFunction · 0.90

Tested by

no test coverage detected