Renamed the format template tag to str_format, and simplify it.
This commit is contained in:
parent
bcb5da1a5e
commit
6bdcdd0d78
@ -25,12 +25,15 @@ First written: 2020/7/1
|
|||||||
|
|
||||||
{% block settings %}
|
{% block settings %}
|
||||||
{% trans "Cash Account for {} in {}" context "Accounting|" as title_format %}
|
{% trans "Cash Account for {} in {}" context "Accounting|" as title_format %}
|
||||||
{% format title_format subject.title_zhtw period.description as title %}
|
{% str_format title_format subject.title_zhtw period.description as title %}
|
||||||
{% setvar "title" title %}
|
{% setvar "title" title %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
{% trans "Cash Account for {} in {}" context "Accounting|" as title_format %}
|
||||||
|
{% str_format title_format subject.title_zhtw period.description as title_format %}
|
||||||
|
<p>{{ title_format }}</p>
|
||||||
<p>{{ request.resolver_match.url_name }}</p>
|
<p>{{ request.resolver_match.url_name }}</p>
|
||||||
<p>{{ request.resolver_match.app_name }}</p>
|
<p>{{ request.resolver_match.app_name }}</p>
|
||||||
|
|
||||||
|
@ -36,17 +36,12 @@ def setvar(context, key, value):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag
|
||||||
def format(context, format, *args, **kwargs):
|
def str_format(format_str, *args):
|
||||||
"""Sets a variable in the template.
|
"""Sets a variable in the template.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
context (Context): the context.
|
format_str (str): The format.
|
||||||
format (str): The format.
|
|
||||||
args (str): The parameters.
|
args (str): The parameters.
|
||||||
kwargs (str): The keyword arguments.
|
|
||||||
"""
|
"""
|
||||||
if "as" in kwargs:
|
return format_str.format(*args)
|
||||||
context.dicts[0][kwargs["as"]] = format.format(*args)
|
|
||||||
return ""
|
|
||||||
return format.format(*args)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user