Skip to content

Working with JsonSchema #148

Answered by verdverm
magick93 asked this question in Q&A
Mar 7, 2023 · 2 comments · 7 replies
Discussion options

You must be logged in to vote

See the txtar file below for details, I changed a bit of your template and added an extra file to demonstrate.

  1. I flip this around a bit. Instead of checking if we are at the first entry, check if we are at the last entry, and skip the comma there. I keep a counter for the map, for lists you can skip this, but they end up looking basically the same. The consistency is nice. Sometimes you have to play with the spacing removers (-) from text/template
  2. For passing multiple inputs to a partial template, use the (dict "key" .value "ROOT" .) helper.
  3. You can use a struct like a map to make a lookup table.

For both 2 & 3, I would enrich the input in CUE before sending to the template. Then just r…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
6 replies
@verdverm
Comment options

@magick93
Comment options

@magick93
Comment options

@magick93
Comment options

@verdverm
Comment options

Answer selected by magick93
Comment options

You must be logged in to vote
1 reply
@verdverm
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants