Comments (5)
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.
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.
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.
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[ ]+[^%])|
(?:</(?!html)
[A-Za-z0-9]+\b[^>]*>
|-->
|<\?(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[ ]%\})
|(?:<(?!\?|area|base|br|col|frame|hr|html|img|input|link|meta|param|[^>]*/>)
([A-Za-z0-9]+)(?=\s|>)\b[^>]*>(?!.*</\1>)
|<!--(?!.*-->)
|<\?php.+?\b(if|else(?:if)?|for(?:each)?|while)\b.*:(?!.*end\1)
|\{[^}"']*))$
</string>
<key>bracketIndentNextLinePattern</key>
<string><!DOCTYPE(?!.*>)</string>
</dict>
<key>uuid</key>
<string>E3351EDC-430A-42E7-9926-6E4C7F34E84F</string>
</dict>
</plist>
from php-twig.tmbundle.
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)
- Twig in Javascript code HOT 2
- Textmate 2 Bundle conflict with PHP HOT 1
- Doesn't work with Sublime Text2 HOT 1
- <nav> not recognized as a block tag
- Script tag breaks the highlighting HOT 2
- {{ }} are not recognized HOT 1
- Foot mark breaks Twig highlighting
- html.twig comments not highlighting correctly
- Weird syntax autocomplete bug when adding a curly brace inside html tags HOT 1
- Vars and functions within HTML attributes not highlighted
- Auto complete for HTML not working HOT 1
- Braces are auto completed, but not percent HOT 1
- Autocomplete of keywords breaks the code
- HTML comments are always printed as Twig comments HOT 4
- Failed to load snippets HOT 2
- Snippet print not working
- wrong indent on {% set foo = bar %} HOT 2
- wrong color on HTML comments <!-- -->
- twig tags inside CSS rules
- Syntax highlighting seems to be broken after upgrading to Sublime 4? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-twig.tmbundle.