Ignore empty lines in indent filter #681#685
Ignore empty lines in indent filter #681#685davidism merged 2 commits intopallets:masterfrom jkfran:master
Conversation
|
Could you please rebase the PR? Generally it's a good idea to use separate branches based off upstream/master for PRs instead of doing the changes in your own master branch. While this can be done when merging a PR, sometimes people merge using a merge commit instead of rebase/squash and in that case the extra noise would remain in the upstream history forever. |
| rv = (u'\n' + indention).join(s.splitlines()) | ||
| lines = s.splitlines() | ||
| rv = lines.pop(0) + u'\n' | ||
| rv += u'\n'.join([indention + l if l else l for l in lines]) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Hello @ThiefMaster thank you! |
ThiefMaster
left a comment
There was a problem hiding this comment.
I'd really like to see some unit tests for this. An optional argument to the filter to keep the old behavior would be nice too - while I don't see any good reason for that behavior people might want it for some reason I can't imagine right now.
| rv = (u'\n' + indention).join(s.splitlines()) | ||
| lines = s.splitlines() | ||
| rv = lines.pop(0) + u'\n' | ||
| rv += u'\n'.join([indention + line if line else line for line in lines]) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Could you add an entry to the changelog file? The PR looks good so far (not a fan of the all-lowercase-no-underscore naming of the argument but the existing one uses the same scheme it's consistent). |
| rv = (u'\n' + indention).join(s.splitlines()) | ||
| else: | ||
| lines = s.splitlines() | ||
| rv = lines.pop(0) + u'\n' |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| else: | ||
| lines = s.splitlines() | ||
| rv = lines.pop(0) + u'\n' | ||
| rv += u'\n'.join(indention + line if line else line for line in lines) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| tmpl = env.from_string('{{ foo|indent(2) }}|{{ foo|indent(2, true) }}') | ||
| text = '\n'.join([' '.join(['foo', 'bar'] * 2)] * 2) | ||
| tmpl = env.from_string('{{ foo|indent(2) }}|' | ||
| '{{ foo|indent(2, true, true) }}') |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| assert out == ('foo bar foo bar\n foo bar foo bar| ' | ||
| 'foo bar foo bar\n foo bar foo bar') | ||
| assert out == ('foo bar\n\n foo baz\n foo bar\n\n foo baz| ' | ||
| 'foo bar\n \n foo baz\n foo bar\n \n foo baz') |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
|
||
|
|
||
| def do_indent(s, width=4, indentfirst=False): | ||
| def do_indent(s, width=4, indentfirst=False, indentblanklines=False): |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
add test for single line update changelog
Ignore empty lines in indent filter #681