Giter Club home page Giter Club logo

Comments (5)

uhnomoli avatar uhnomoli commented on July 22, 2024

I'm not sure exactly what you're asking here. Can you give me an example of the observed and expected behavior?

from php-twig.tmbundle.

leopoiroux avatar leopoiroux commented on July 22, 2024

Hi,
If you paste this code in SublimeText and you go on "Edit >> Line >> Reindent". The indentation is not respected. See the result :

{% if condition %}
{% for key, val in array %}
{{ val }}
{% endfor %}
{% else %}
{{ my_other_value }}
{% endif %}

from php-twig.tmbundle.

pimpreneil avatar pimpreneil commented on July 22, 2024

I have the same problem:
The automatic indentation (command Indentation:Reindent Lines) of my twig blocks between each other is not working.
Indeed, the twig coding standards stipulates that you should "Indent your code inside tags (use the same indentation as the one used for the target language of the rendered template)" c.f.: http://twig.sensiolabs.org/doc/coding_standards.html.

Using your bundle, I get that:

{% if condition %}
{% for key, val in array %}
{{ val }}
{% endfor %}
{% else %}
{{ my_other_value }}
{% endif %}
{% for item in seq %}

Instead of that:

{% if condition %}
    {% for key, val in array %}
        {{ val }}
    {% endfor %}
{% else %}
    {{ my_other_value }}
{% endif %}

from php-twig.tmbundle.

pimpreneil avatar pimpreneil commented on July 22, 2024

I have started writing a tmPreference file to handle a proper indentation for twig. Here it is

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>name</key>
    <string>Indent</string>
    <key>scope</key>
    <string>text.html.twig</string>
    <key>settings</key>
    <dict>
        <key>decreaseIndentPattern</key>
        <string>(?x)
        ^\s*
        (?:
        (?:\{%[ ]end[^}]+[ ]%\})|
        (?:\{%[ ]else[ ]%\})|
        (?:\{%[ ]elseif[ ]+[^%])|
        (?:&lt;/(?!html)
          [A-Za-z0-9]+\b[^&gt;]*&gt;
        |--&gt;
        |&lt;\?(php)?\s+(else(if)?|end(if|for(each)?|while))
        |\}
        ))</string>
        <key>increaseIndentPattern</key>
        <string>(?x)
        ^\s*
        (?:
        (?:\{%[ ](?!import|extends|end|include|form_theme|set|do)(?:[^ ]*)[ ][^%]*%\})
        |(?:\{%[ ]set[ ]%\})
        |(?:&lt;(?!\?|area|base|br|col|frame|hr|html|img|input|link|meta|param|[^&gt;]*/&gt;)
          ([A-Za-z0-9]+)(?=\s|&gt;)\b[^&gt;]*&gt;(?!.*&lt;/\1&gt;)
        |&lt;!--(?!.*--&gt;)
        |&lt;\?php.+?\b(if|else(?:if)?|for(?:each)?|while)\b.*:(?!.*end\1)
        |\{[^}"']*))$
        </string>
        <key>bracketIndentNextLinePattern</key>
        <string>&lt;!DOCTYPE(?!.*&gt;)</string>
    </dict>
    <key>uuid</key>
    <string>E3351EDC-430A-42E7-9926-6E4C7F34E84F</string>
</dict>
</plist>

from php-twig.tmbundle.

uhnomoli avatar uhnomoli commented on July 22, 2024

I've added an indentation preferences file. Feel free to reopen this issue if experience any issues with it.

from php-twig.tmbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.