Closed valentine195 closed 2 years ago
The convertJson routine in my plugin takes a jsonfile which contains an array of records and creates many files, one per record in the array.
If that is what is required then I can probably make it an easy exported method.
--
If you only require a single record to be processed then it might be quicker to grab just the few lines required:
85 (JSON.parse)
88-92 (sets up handlebars)
125 (let body = template(jsondata)).
On 16/01/2022 00:09, Jeremy Valentine wrote:
Hey! I was thinking about adding the ability to specify import templates using handlebars for the TTRPG Statblocks plugin, and realized that you already did the hard work :)
Would it be possible for you to create a generic method I could pass a json file and handlebars template file to, and get back the parsed file?
— Reply to this email directly, view it on GitHub https://github.com/farling42/obsidian-import-json/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFM4SCXQT245SRR55WNRDLUWIECBANCNFSM5MBSPXLA. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Yup, basically. The idea would be to pass a file of JSON array of objects and a handlebars file and get back the array of monsters.
Edit: but yeah, no worries - I can just pull out the code too. Probably easier in the end 😁
My version adds the files directly into the vault in a named location; I don't know if you would want them there.
It is only half a dozen lines - the main thing is to initialize the handlebars thing only once per batch. :)
Thanks for the heads up!
Hey! I was thinking about adding the ability to specify import templates using handlebars for the TTRPG Statblocks plugin, and realized that you already did the hard work :)
Would it be possible for you to create a generic method I could pass a json file and handlebars template file to, and get back the parsed file?