Closed Destroy666x closed 1 year ago
i think if i use https://github.com/pantor/inja it will enable everything and more
you can use loops and expressions in the {{ .. }}
Sounds good
implemented inja in #39
The Windows build failed for now.
The Windows build failed for now.
@Destroy666x windows build works now.
It's "Output Template" that's being rendered, right? First suggestion would be to turn that into a TextEdit textbox then. As from what I see inja loops have multiline syntax.
Another thing is how things are passed into the engine - e.g. array of objects seems to be text.
i can just send the whole parsed response (in case of JSON) and you can use inja to manipulate it as you wish
Not sure about parsed response and how well Inja supports getting data out of it, but whole object/array would be nice for sure.
implemented in #39
Any examples of how to do it with let's say this kind of JSON:
[
{
"something": "something"
},
{
"something": "else"
}
]
?
And format it as something | else | ...
Not too sure how it was solved in the end looking at source.
Example:
$
{{output}}
results in:
[{"fact":"..."},{...}]
kind of output.
I'd expect:
{% for fact in output %}
{{fact.fact}}
{% endfor %}
to cycle it, but I can't reall get it or anything similar to work. Also with body
instead of output
.
Ok, nvm, e.g.
{% for fact in body %}
{{fact.fact}} |||||
{% endfor %}
is in fact working, but it's not fully stable, as I had to hide and show the source for it to be displayes, otherwise it just showed as is. Not too sure what's going on. But I think it's more of a problem with coming back to working state after inja errors out so I'll create a new bug and'll close this as finished.
I guess there's one more question. With the example above, if I use:
$[*].fact
body
doesn't seem to change compared to $
, it's still just the whole JSON. Is there any way to access that specific JSON path as an array or object specifically, just like body
? So that you could use e.g. {{ join(array, " | ") }}
@royshil impossible, I assume?
@Destroy666x i'm not fully following you can you provide a worked example? e.g. with the JSON body and the desired output?
@royshil example is like mentioned above:
[
{
"fact": "something"
},
{
"fact": "else"
}
]
$[*].fact
body
is for whole JSON output as the result is the same for the JSON path above and also for $
(root), even though results are different. Is there any way to have the JSON Path output as body
or another variable? I don't think it's possible but I may have missed something.
I'd like to feed the result of that JSON Path to {{ join(body, " | ") }}
as body
@Destroy666x let's take this to another clean issue just copy-paste plz
Separator setting would be really handy to quickly style output for e.g. news tickers and similar things.
Currently you can, as far as I know:
{output0} | {output1} | {output...}
kind of output if there are multiple, but that's not too efficient and readable to set up if there are let's say 50 or 100 parts