Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected macro syntax violation #170

Open
cedric-anne opened this issue Feb 16, 2021 · 2 comments
Open

Unexpected macro syntax violation #170

cedric-anne opened this issue Feb 16, 2021 · 2 comments

Comments

@cedric-anne
Copy link
Contributor

In Twig documentation, there are space surrounding the = operator in macro declarations.

Problem is that this syntax is reported as errored by the rule responsible to check named arguments declaration.

Macro declaration:

{% macro test(title, test = true) %}
    ...
{% endmacro %}

Error reported: l.1 c.25 : ERROR There should be 0 space before the "=" in the named arguments list.

@OwlyCode
Copy link
Collaborator

Hi,

Good catch! This would need to be fixed and then added to our test suite.

@alexander-schranz
Copy link

I have a similar case where html code seems to be detected as twig the data-controller="expander":

<!-- overlay -->
<div id="{{ id }}" class="relative z-10 hidden" role="dialog" aria-modal="true">
    <div class="fixed inset-0 bg-black bg-opacity-50 transition-opacity cursor-default"
         data-controller="expander"
         data-action="click->expander#close"
         aria-controls="{{ id }}"
         aria-expanded="false"></div>

    <div class="fixed z-10 w-screen sm:w-[85vw] max-w-screen-md bottom-0 sm:bottom-auto sm:top-1/2 left-1/2 -translate-x-1/2 sm:-translate-y-1/2 bg-white rounded-t-lg sm:rounded-lg shadow-lg">
        <div class="absolute top-0 right-4 pt-4 pl-2 pb-2 bg-white rounded-bl-xl">
            <button type="button" class="bg-white rounded-md text-primary-600 hover:text-primary-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500"
                    data-controller="expander"
                    data-action="expander#close"
                    aria-controls="{{ id }}"
                    aria-expanded="false">
                <span class="sr-only">{{ 'app.close'|trans }}</span>
                {{ include('website/atoms/icons/outline/x.html.twig', {class: 'h-6 w-6'}) }}
            </button>
        </div>

        <div class="max-h-[90vh] sm:max-h-[85vh] overflow-y-auto p-5 pt-8 sm:p-10 overscroll-y-contain">
            {% if title|default %}
                <h3 class="text-2xl leading-8 font-bold text-slate-600 mb-10">{{ title }}</h3>
            {% endif %}

            <div>
                {% block content %}{% endblock %}
            </div>
        </div>
    </div>
</div>
        {
            "file": "templates\/molecules\/overlay.html.twig",
            "violations": [
                {
                    "line": 12,
                    "column": 120,
                    "severity": 3,
                    "type": "error",
                    "message": "There should be 0 space before the \"=\" in the named arguments list."
                },
                {
                    "line": 12,
                    "column": 122,
                    "severity": 3,
                    "type": "error",
                    "message": "There should be 0 space after the \"=\" in the named arguments list."
                }
            ]
        },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants