mustache / vim-mustache-handlebars

mustache and handlebars mode for vim
mustache.github.io
455 stars 49 forks source link

Hanging attributes #55

Open AndrewRadev opened 7 years ago

AndrewRadev commented 7 years ago

This PR implements a "hanging" attribute style. If the first line of the component has at least one attribute set on that line, the rest align according to that. So, it looks like this:

{{foo-bar one="two"
          two="three"
          four="five"}}

If the first line only has the component name, and not an attribute, it indents like it did before.

Unfortunately, I branched this PR off from my own master, which includes PRs #53 and #52. Depending on what you decide, I can rebase this on top of your master, but for now, I'll just leave it here for consideration as-is.

nelstrom commented 7 years ago

I'd love to see this merged. In the meantime, I've switched to using AndrewRadev/vim-mustache-handlebars.

shadoath commented 5 years ago

Bump. Is this repo being actively maintained?

jsit commented 5 years ago

@AndrewRadev Can you please resolve these conflicts?

AndrewRadev commented 5 years ago

I've rebased the branch on top of the current master (or rather, cherry-picked the changes without the variable renames), and I've fixed a bug I'd introduced. I'd recommend testing it out before merging, though, indentation is tricky.

AndrewRadev commented 4 years ago

I've merged the most recent master, and tested it out a bit, and it seems to work well now after #93. If you have time to test it out and find any issues to fix, let me know.

jsit commented 4 years ago

Thanks @AndrewRadev. Can you please add some test cases to example.mustache?

AndrewRadev commented 4 years ago

@jsit I've pushed an example of component with hanging attributes, and I've also applied a fix for that file -- it had an unclosed <a> tag.

That said, I see there's a new example there of an angle-brackets component that doesn't seem to indent correctly:

<AngleBracketComponent
@mustache={{@bla}}
@number=123
data-test-id="test"
class="my-class" as |test|>
Some Text
<div>{{test.someValue}}</div>
<test.component teste="asdfads"></test.component>
</AngleBraketComponent>

But actually, even when I change to master, it still doesn't indent correctly, so that doesn't seem to be a regression from this PR. It might be something that's just not handled on my config and expects maybe HTML support to deal with it.

Well, either way, it seems like an unrelated issue.

jsit commented 4 years ago

@AndrewRadev Thanks; I've already got an issue for the angle bracket indent issue, #92

Will have a look at your hanging example now, thank you!

jsit commented 4 years ago

@AndrewRadev Also curious to get your opinion on #98

AndrewRadev commented 4 years ago

I think I've addressed your comments -- let me know what you think.

@AndrewRadev Also curious to get your opinion on #98

Yes, that seems like a very sensible change. I remember being confused by the explicit runtimes of syntax and indent scripts, it would be much easier to understand to just have separate handlebars and mustache files where one includes the other.

jsit commented 4 years ago

An issue here: if I'm typing out a mustache element, rather than indenting one with =, it stops correctly doing the hanging indent after the second line:

Screen Shot 2020-08-09 at 5 26 13 PM

Although this seems to be an issue on master, too, with standard blocks:

Screen Shot 2020-08-09 at 5 28 42 PM

Edit: Filed #99 for this unrelated issue.