Knotx / knotx

Knot.x is a highly-efficient and scalable integration framework designed to build backend APIs
https://knotx.io
Apache License 2.0
126 stars 26 forks source link

Change default snippet tag #462

Closed pun-ky closed 4 years ago

pun-ky commented 5 years ago

Imagine case related with server side rendering in which I need to have both markup rendered and pure JSON beside of:

<script data-knotx-knots="databridge,handlebars" data-knotx-databridge-name="someSearch" type="text/knotx-snippet">
    {{#string_equals _response.statusCode "200"}}
        <script type="application/json">
            {{{_result}}}
        </script>

<ul class="items">
     {{#each _result.response.docs}}
    <li>
     <!-- .... -->
    </li>
     {{/each}}
</ul>

    {{/string_equals}}
</script>

and in case of HTL , nested script will be not rendered or will be not HTML compliant markup, but.... if we change knot.x snippet tag to be template tag by default, it will be correct. What is more nested template tags are valid in HTML, so that I am convinced that it just gives more flexibility without a need to configure https://github.com/Cognifide/knotx/blob/master/documentation/src/main/cheatsheet/cheatsheets.adoc#snippetoptions .

I know that it is a breaking change, but maybe it is worth to be considered when releasing next major version.

marcinczeczko commented 5 years ago

But why you're putting the handlebars markup outside knotx snippet ? nothing stops you rendering it as knotx snippet

pun-ky commented 5 years ago

mislooking when preparing example snippet ;) / edited.

pun-ky commented 5 years ago

how about even non-html knotx snippet in a form of template engine like using e.g handlebars comment syntax?

{{!--knotxSnippet(knots="databridge,handlebars" databridge-name="someSearch")--}}

    {{#string_equals _response.statusCode "200"}}
        <script type="application/json">
            {{{_result}}}
        </script>

<ul class="items">
     {{#each _result.response.docs}}
    <li>
     <!-- .... -->
    </li>
     {{/each}}
</ul>

    {{/string_equals}}

--}}

this will give ability to inject knotx into partial json, xml and so on...

pun-ky commented 5 years ago

what is more I am worried about nested e.g Githubissues.

  • Githubissues is a development platform for aggregating issues.