FeatureBrowser/FeatureBrowser

View on GitHub
src/FeatureBrowser/Resources/views/macros/feature-macros.html.twig

Summary

Maintainability
Test Coverage
{% macro feature(relativePath, filename, anchor, title) %}
    <a href="{{ relativePath }}directories/{{ filename }}{% if anchor %}#{{ anchor }}{% endif %}">{{ title }}</a>
{% endmacro %}

{% macro tablenode(table) %}
    <table class="table table-striped table-bordered">
        {% for row in table.getRows() %}
        {% if loop.first %}
        <thead>
        <tr>
            {% for cell in row %}
                <th>{{ cell }}</th>
            {% endfor %}
        </tr>
        </thead>
        <tbody>
        {% else %}
            <tr>
                {% for cell in row %}
                    <td>{{ cell }}</td>
                {% endfor %}
            </tr>
        {% endif %}
        {% endfor %}
        </tbody>
    </table>
{% endmacro %}

{% macro stepnode(step) %}
    {% import _self as macros %}
    {{ step.getKeyword() }} {{ step.getText() }}<br/>
    {% if step.hasArguments() %}
        {% for argument in step.getArguments() %}
            {% if argument.getNodeType() == 'Table' %}
                {{ macros.tablenode(argument) }}
            {% endif %}
        {% endfor %}
    {% endif %}
{% endmacro %}

{% macro scenarionode(feature, scenario) %}
    {% import _self as macros %}
    <p>
        {% for step in feature.getBackground().getSteps() %}
            {{ step.getKeyword() }} {{ step.getText() }}<br/>
        {% endfor %}
        {% for step in scenario.getSteps() %}
            {{ macros.stepnode(step) }}
        {% endfor %}
    </p>
{% endmacro %}