orellazri / renderkit

A swiss army knife CLI tool for rendering templates
GNU General Public License v3.0
22 stars 0 forks source link

Load CSV file #66

Open bersace opened 3 months ago

bersace commented 3 months ago

Hi,

Thanks for renderkit, it look awesome. I was wondering for such project for a few monthes ! I need to load CSV file, what do you think of it ?

Regards, Étienne

orellazri commented 3 months ago

Hey! Thanks, that’s great to hear! Do you mean using a CSV file as a datasource? If so, how would the key-value pairs be laid out? Perhaps in a way that each line will contain key,value?

Let me know if that’s not what you meant :)

bersace commented 3 months ago

Yep, I mean CSV datasource. The simplest case is just a two dimensional array of strings.

{{ range .Csv }}
{{   range .Columns }}
{{     . }}
{{   end }}
{{ end }}

Would it work like that ?

orellazri commented 3 months ago

@bersace we currently support key-value pairs, that are merged from all datasources, so in your case the template will still reference the variables from the key names like with the other datasources. I'm not sure how useful it would be then, but this can be considered. You can also feel free to create a PR if you'd like!