static final String generateForFragment(RuleBuilderStep step, Configuration configuration) {
        final String fragmentName = step.function();
        try {
            Template template = configuration.getTemplate(fragmentName);
            StringWriter writer = new StringWriter();
            Map<String, Object> filteredParams = new HashMap<>();
            if (step.parameters() != null) {
                for (Map.Entry<String, Object> val : step.parameters().entrySet()) {
                    if (val.getValue() instanceof String s) {
                        if (StringUtils.isBlank(s)) {
                        } else if (s.startsWith("$")) {
                            filteredParams.put(val.getKey(), s.substring(1));
                        } else {
                            filteredParams.put(val.getKey(), "\"" + s + "\"");
                        }
                    } else {
                        filteredParams.put(val.getKey(), val.getValue());
                    }
                }
            }
            template.process(filteredParams, writer);
            writer.close();
            return writer.toString();
        } catch (TemplateNotFoundException e) {
            throw new IllegalArgumentException(f("No template found for fragment %s", fragmentName));
        } catch (Exception e) {
            throw new IllegalArgumentException("Error converting fragment template to fragment.", e);
        }

    }
@Test
    public void generateForFragmentConvertsFreemarkerTemplate() {
        RuleBuilderStep step = mock(RuleBuilderStep.class);
        when(step.function()).thenReturn("test_fragment1");
        Map<String, Object> params = Map.of("field", "my_field");
        when(step.parameters()).thenReturn(params);
        assertThat(ParserUtil.generateForFragment(step, configuration))
                .isEqualTo("let gl2_fragmentvar_v1 = $message.\"my_field\";");
    }