-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Preserve/inherit indentation levels. #237
Preserve/inherit indentation levels. #237
Conversation
@wycats, what are your thoughts on this? |
Update: I was realizing yesterday that partials are only half the battle. This has the same behavior too: <html>
<body>
{{{body}}}
</body>
</html> With that said, whatever the stance is, let's not merge this in until I can get this part fixed too. And with that addition, I want to make the indentation behavior completely optional (via something like |
@brianreavis Sorry we've been so slow in reviewing this. Is there any chance you could rebase to get this to merge cleanly? Maybe also squash down some of the commits while you're at it. |
Also, is it possible for you to write tests for this? |
My main concern about stuff like this (similar to #336) is that it introduces seemingly-magic behavior in order to achieve whitespace-related behavior that particular use-cases consider appropriate. On the flip-side, in whitespace-sensitive situations ( Simply making it an option doesn't really help the situation, since most people will see the problematic behavior, get frustrated by the situation, and never find the option. Making it a flag you need to turn on manually will help the people who submitted the ticket, but again, very few people who need the behavior will find the flag. Because of these opposing constraints, my inclination is to have the output consistently do what it says, and not mess around with whitespace. I could probably be persuaded to support a flag, if the pull request came with a doc-patch to handlebars-site and tests. For now, I'm closing this. Please reopen if you have a more complete patch. Thanks! |
I would very much like to see this in a future version. |
This fix is purely aesthetic, but I think it's pretty important (especially at DIY where we hope to have kids reading the page source). Currently with handlebars, using partials causes indentation levels of the output to get borked. Here's the scenario:
"head" partial:
Current Output:
Fixed Output:
With this update, the output looks like this:
The update reads the indentation level of the last line of the
content
block preceding the partial, and transfers it to every line of the partial output (except the first). Works with spaces, tabs, or a mixture of the two.Note: I made sure that the modifications to
runtime.js
will not break existing precompiled templates.(p.s. Sorry for submitting this twice... I forgot about another change I wanted to submit as a separate pull request, so I had to set up some branches.)