Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

render template that it is contains one '\r\n' string will return more than one

Open
#1,087 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
backend

Research direction

Start with the Jinjava render invocation and the withLstripBlocks(true)/withTrimBlocks(true) configuration shown in the report. Reproduce the CRLF template with all three variables set, then trace how block trimming handles '\r\n'; add a regression test for the expected rendered line spacing.

Written by the indexing model from the issue text.

Description

render method with config withLstripBlocks(true).withTrimBlocks(true)


public static String render(String template, Map<String,Object> params) {
        final JinjavaConfig config = JinjavaConfig
                .newBuilder()
                .withLstripBlocks(true).withTrimBlocks(true).build();
        final Jinjava jinjava = new Jinjava(config);
        final JinjavaInterpreter jinjavaInterpreter = jinjava.newInterpreter();
        jinjavaInterpreter.getContext().putAll(params);
        final String renderStr = jinjavaInterpreter.render(jinjavaInterpreter.parse(template));
        return renderStr;
 }

test code:

  
         String template = "{% if bootefiDev %}\r\n" +
                "part /boot/efi --fstype=\"efi\" --size=500 --ondisk={{ bootefiDev }}\r\n" +
                "{% endif %}\r\n" +
                "{% if bootDev %}\r\n" +
                "part /boot --fstype ext4 --size=2048 --ondisk={{ bootDev }}\r\n" +
                "{% endif %}\r\n" +
                "{% if rootDev %}\r\n" +
                "part / --fstype ext4 --size=1 --grow  --ondisk={{ rootDev }}\r\n" +
                "{% endif %}\r\n";
        Map<String,Object> param = new HashMap<>();
        param.put("bootefiDev","sda");
        param.put("bootDev","sda");
        param.put("rootDev","sda");
        System.out.println(render(template,param));
 

and then i will get a render result below:

part /boot/efi --fstype="efi" --size=500 --ondisk=sda


part /boot --fstype ext4 --size=2048 --ondisk=sda


part / --fstype ext4 --size=1 --grow  --ondisk=sda

Dominant language
Java
Stars
785
Forks
184
Avg merge
6d 22h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HubSpot/jinjava

All issues in HubSpot/jinjava

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.