-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Indent code in Go HTML templates #709
Conversation
I have made a test template to try to cover all cases, hope it could be helpful.
|
I can take a look in the next few days.
|
Thanks @cespare 👍 |
This change doesn't work for me at all, because the |
@jinzhu any comments on that ? |
Hi @cespare This method is defined in vim, file |
Maybe we should add a clause to check if this exists or not by checking the version and patch level. An example how to do it: http://vi.stackexchange.com/a/2467/2791 |
BTW I'm using a fairly recent vim (7.4 something, can't check the exact version at the moment). I suspect that calling this function is the wrong approach in general. When I look at indent files for other templating languages, they don't do it this way. Example: https://github.com/mitsuhiko/vim-jinja/blob/master/indent/htmljinja.vim |
I just pushed another commit, fixed it doesn't work on vim 7.3, I have tested new fix with below three versions, all works for me. @cespare could you test it works for you or not?
I think vim-jinja is just using another solution to make things works, from github search results count, it is less used that current solution. I haven't found much documents about this when writing the code, so just pick up a simper solution. ;) |
Works for me. LGTM. |
" If need to indent based on last line | ||
let last_line = getline(a:lnum-1) | ||
if last_line =~ '^\s*{{\s*\%(if\|else\|range\|with\|define\|block\).*}}' | ||
let ind = ind + sw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let ind += sw
@jinzhu this looks good. Can you squash it into one commit if possible? |
@fatih sure, just did this ;) |
Indent code in Go HTML templates
Thanks @jinzhu for the contribution 👍 |
Before when write go code in templates, it is not indented correctly, for example:
I think this should be indented to:
This pull request did the job, fixed the indention for
if/else
,range
,with
,block
,define