{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% block toolbar %}
    {% set icon %}
        <span class="sf-toolbar-label">
            {{ include('@WebProfilerModule/debug/dataCollector/Icon/smarty.svg') }}
        </span>
        <span class="sf-toolbar-value">{{ collector.totalExecutionTime is defined ? collector.totalExecutionTime : 'n/a' }} </span>
        <span class="sf-toolbar-label">ms</span>

        {% set text %}
            <div class="sf-toolbar-info-piece">
                <b>Render Time</b>
                <span>{{ collector.totalExecutionTime is defined ? collector.totalExecutionTime : 'n/a' }} ms</span>
            </div>
            <div class="sf-toolbar-info-piece">
                <b>Template Calls</b>
                <span class="sf-toolbar-status">{{ collector.templatecount }}</span>
            </div>
        {% endset %}
    {% endset %}

    {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true, name: 'smarty', status: '', block_attrs: 'title=""' }) }}
{% endblock %}

{% block menu %}
    <span class="label {{ 0 == collector.templateCount ? 'disabled' }}">
        <span class="icon">{{ include('@WebProfilerModule/debug/dataCollector/Icon/smarty.svg') }}</span>
        <strong>Smarty</strong>
    </span>
{% endblock %}

{% block panel %}
    {% if collector.templatecount == 0 %}
        <h2>Smarty</h2>

        <div class="empty">
            <p>No smarty templates were rendered for this request.</p>
        </div>
    {% else %}
        <h2>Smarty Metrics</h2>

        <div class="metrics">
            <div class="metric">
                <span class="value">{{ collector.totalExecutionTime is defined ? collector.totalExecutionTime : 'n/a' }} <span class="unit">ms</span></span>
                <span class="label">Render time</span>
            </div>

            <div class="metric">
                <span class="value">{{ collector.templatecount }}</span>
                <span class="label">Template calls</span>
            </div>
        </div>

        <p class="help">
            Render time includes sub-requests rendering time (if any).
        </p>

        <h2>Rendered Templates</h2>

        <table id="twig-table">
            <thead>
            <tr>
                <th scope="col">Template Name &amp; Path</th>
                <th scope="col">Render time</th>
            </tr>
            </thead>
            <tbody>
            {% for template in collector.templates %}
                {%- set file = template.name -%}
                {%- set link = file ? file|file_link(1) : false -%}
                <tr>
                    <td>
                        <span class="sf-icon icon-twig">{{ include('@WebProfilerModule/debug/dataCollector/Icon/smartyColor.svg') }}</span>
                        {% if link %}
                            <a href="{{ link }}" title="{{ file }}">{{ template.name }}</a>
                            <div>
                                <a class="text-muted" href="{{ link }}" title="{{ file }}">
                                    {{ file|file_relative|default(file) }}
                                </a>
                            </div>
                        {% else %}
                            {{ template.name }}
                        {% endif %}
                    </td>
                    <td>
                        {{ template.executionTime }}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    {% endif %}
{% endblock %}
