0

有谁知道使用列名覆盖而不是视图中定义的名称的液体模板变量名称?

<th width="{{ c.width }}" class="govuk-table__header" data-logicalname="{{ c.logical_name }}">
    {% if c.sort_enabled %}
        {% assign current_sort = order | current_sort:c.logical_name %}
        {% case current_sort %}
            {% when 'ASC' %}
                <a href="{{ request.path_and_query | add_query:'order', c.sort_descending }}"><i class="fa fa-sort-asc"></i>
                {{ c.name }}
                </a>
                {% when 'DESC' %}
                <a href="{{ request.path_and_query | add_query:'order', c.sort_ascending }}"><i class="fa fa-sort-desc"></i>
                {{ c.name }}
                </a>
                {% else %}
                <a href="{{ request.path_and_query | add_query:'order', c.sort_ascending }}"><i class="fa fa-sort-desc fa-rotate-270"></i>
                {{ c.name }}
                </a>
            {% endcase %}
    {% else %}
        {{ c.name }}
    {% endif %}
</th>

我目前正在使用c.name,但我希望名称继承实体列表配置中的列名属性。

4

1 回答 1

0

ASAIK 这是不可能的,您需要将逻辑添加到模板中以重命名列名,请参见下面的“XXXXXXXXXX”:

{% if c.logical_name == "XXXXXXXXXX" %}


<th width="{{ c.width }}" class="govuk-table__header" data-logicalname="{{ c.logical_name }}">
    {% if c.sort_enabled %}
        {% assign current_sort = order | current_sort:c.logical_name %}
        {% case current_sort %}
            {% when 'ASC' %}
                <a href="{{ request.path_and_query | add_query:'order', c.sort_descending }}"><i class="fa fa-sort-asc"></i>
                XXXXXXXXXX
                </a>
                {% when 'DESC' %}
                <a href="{{ request.path_and_query | add_query:'order', c.sort_ascending }}"><i class="fa fa-sort-desc"></i>
                XXXXXXXXXX
                </a>
                {% else %}
                <a href="{{ request.path_and_query | add_query:'order', c.sort_ascending }}"><i class="fa fa-sort-desc fa-rotate-270"></i>
                XXXXXXXXXX
                </a>
            {% endcase %}
    {% else %}
        {{ c.name }}
    {% endif %}
</th>
{% else %}
<th width="{{ c.width }}" class="govuk-table__header" data-logicalname="{{ c.logical_name }}">
    {% if c.sort_enabled %}
        {% assign current_sort = order | current_sort:c.logical_name %}
        {% case current_sort %}
            {% when 'ASC' %}
                <a href="{{ request.path_and_query | add_query:'order', c.sort_descending }}"><i class="fa fa-sort-asc"></i>
                {{ c.name }}
                </a>
                {% when 'DESC' %}
                <a href="{{ request.path_and_query | add_query:'order', c.sort_ascending }}"><i class="fa fa-sort-desc"></i>
                {{ c.name }}
                </a>
                {% else %}
                <a href="{{ request.path_and_query | add_query:'order', c.sort_ascending }}"><i class="fa fa-sort-desc fa-rotate-270"></i>
                {{ c.name }}
                </a>
            {% endcase %}
    {% else %}
        {{ c.name }}
    {% endif %}
</th>
{% endif %}
于 2020-12-03T22:51:15.003 回答