de-jcup / eclipse-hijson-editor

Highspeed JSON editor
https://marketplace.eclipse.org/content/hijson-editor
Apache License 2.0
8 stars 1 forks source link

Provide thymeleaf templating #21

Open de-jcup opened 2 years ago

de-jcup commented 2 years ago

Situation

{[#th:block th:with="sarifSupport=${new org.zaproxy.addon.reports.sarif.SarifReportDataSupport(reportData)}"]
   "runs": [
      {
         "results": [ [#th:block th:each="sarifResult, sarifResultState: ${sarifSupport.results}"]
...
[/th:block]],

shows an example for a thymeleaf template (see https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#textual-template-modes)

Unfortunately we have no outline here inside the editor and an error is shown because not valid JSON (what is correct).

Wanted

Solution

Example1

[# th:each="message : ${messages}"]
                "message": {
                  "text": [[${sarifResult.message.text}]]
               },
[/]

will be replaced internally to


                "message": {
                  "text": []
               },

Example2

[#th:each="message : ${messages}"]
                "message": {
                  "level": "[(${sarifResult.level.value})]",
               },
[/th:each]

will be replaced internally to


                "message": {
                  "level": ""
               },

Detection howto

Everything starting with [# marks a thymeleaf beginning tag, terminated by ] [/ marks a thymeleaf end tag, terminated by ]