Skip to content
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 macro adds extra newline #1231

Comments

@agirardeaudale
Copy link

agirardeaudale commented Jul 5, 2019

Running via Node 10.16.0 on Windows through WSL/Ubuntu, I find that the indent macro is adding an additional trailing newline character.

Example Input:

### Block Filter
{% filter indent(4) -%}
A
B
C
{%- endfilter %}
###


{% macro letters() -%}
A
B
C
{%- endmacro -%}

### Filter with macro
{{ letters() | indent(4) }}
###

Expected Output:

### Block Filter
A
    B
    C
###


### Filter with macro
A
    B
    C
###

Actual Output:

### Block Filter
A
    B
    C

###


### Filter with macro
A
    B
    C

###

The expected output is what I see when I run the same template through Jinja in Python. I've checked that all of the line break characters are newlines and not carriage returns. Interestingly, Nunjucks is also adding an additional newline to the end of the file, I'm not sure if that's by design. I haven't noticed an extra newline when using any tags or filters besides indent.

@gilesvessey
Copy link

I am also running into this issue. Probably going to write a template filter to indent without the added newline, but I shouldn't have to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment