render template that it is contains one '\r\n' string will return more than one
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from HubSpot/jinjava
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
Jinjava 3.0 Open
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
elastic/gradle-plugins#157 ·
-
enhancement Tools
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
apache/rocketmq-dashboard#5008 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
DETECT_PARAMETER_NAMES=false silently disables @ConstructorProperties-based Creator detection too Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
FasterXML/jackson-databind#6229 ·