Remove leading underscore from a function that's all growed up now.
This function is now the de facto standard function for rendering values in a template, and is imported by two other built-in template modules. It shouldn't have a leading underscore.
This commit is contained in:
parent
8f839aaa18
commit
3ded2aef71
|
@ -861,7 +861,7 @@ class TextNode(Node):
|
|||
def render(self, context):
|
||||
return self.s
|
||||
|
||||
def _render_value_in_context(value, context):
|
||||
def render_value_in_context(value, context):
|
||||
"""
|
||||
Converts any value to a string to become part of a rendered template. This
|
||||
means escaping, if required, and conversion to a unicode object. If value
|
||||
|
@ -891,7 +891,7 @@ class VariableNode(Node):
|
|||
# control (e.g. exception rendering). In that case, we fail
|
||||
# quietly.
|
||||
return ''
|
||||
return _render_value_in_context(output, context)
|
||||
return render_value_in_context(output, context)
|
||||
|
||||
# Regex for token keyword arguments
|
||||
kwarg_re = re.compile(r"(?:(\w+)=)?(.+)")
|
||||
|
|
|
@ -13,7 +13,7 @@ from django.template.base import (Node, NodeList, Template, Context, Library,
|
|||
BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END,
|
||||
SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END,
|
||||
VARIABLE_ATTRIBUTE_SEPARATOR, get_library, token_kwargs, kwarg_re,
|
||||
_render_value_in_context)
|
||||
render_value_in_context)
|
||||
from django.template.smartif import IfParser, Literal
|
||||
from django.template.defaultfilters import date
|
||||
from django.utils.encoding import smart_text
|
||||
|
@ -78,7 +78,7 @@ class CycleNode(Node):
|
|||
return ''
|
||||
if not self.escape:
|
||||
value = mark_safe(value)
|
||||
return _render_value_in_context(value, context)
|
||||
return render_value_in_context(value, context)
|
||||
|
||||
class DebugNode(Node):
|
||||
def render(self, context):
|
||||
|
@ -111,7 +111,7 @@ class FirstOfNode(Node):
|
|||
if value:
|
||||
if not self.escape:
|
||||
value = mark_safe(value)
|
||||
return _render_value_in_context(value, context)
|
||||
return render_value_in_context(value, context)
|
||||
return ''
|
||||
|
||||
class ForNode(Node):
|
||||
|
|
|
@ -3,7 +3,7 @@ import re
|
|||
|
||||
from django.template import (Node, Variable, TemplateSyntaxError,
|
||||
TokenParser, Library, TOKEN_TEXT, TOKEN_VAR)
|
||||
from django.template.base import _render_value_in_context
|
||||
from django.template.base import render_value_in_context
|
||||
from django.template.defaulttags import token_kwargs
|
||||
from django.utils import six
|
||||
from django.utils import translation
|
||||
|
@ -87,7 +87,7 @@ class TranslateNode(Node):
|
|||
self.filter_expression.var.message_context = (
|
||||
self.message_context.resolve(context))
|
||||
output = self.filter_expression.resolve(context)
|
||||
value = _render_value_in_context(output, context)
|
||||
value = render_value_in_context(output, context)
|
||||
if self.asvar:
|
||||
context[self.asvar] = value
|
||||
return ''
|
||||
|
@ -143,7 +143,7 @@ class BlockTranslateNode(Node):
|
|||
result = translation.pgettext(message_context, singular)
|
||||
else:
|
||||
result = translation.ugettext(singular)
|
||||
data = dict([(v, _render_value_in_context(context.get(v, ''), context)) for v in vars])
|
||||
data = dict([(v, render_value_in_context(context.get(v, ''), context)) for v in vars])
|
||||
context.pop()
|
||||
try:
|
||||
result = result % data
|
||||
|
|
Loading…
Reference in New Issue