We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
render method with config withLstripBlocks(true).withTrimBlocks(true)
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
The text was updated successfully, but these errors were encountered:
No branches or pull requests
render method with config
withLstripBlocks(true).withTrimBlocks(true)
test code:
and then i will get a render result below:
The text was updated successfully, but these errors were encountered: