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)
| 1137 | |
| 1138 | |
| 1139 | def 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 | |
| 1155 | class VariableNode(Node): |
no test coverage detected