Stream: IG creation
Topic: New IG template approach - custom Jekyll variables?
Rob Eastwood (Mar 09 2020 at 05:16):
We are looking to make use of Jekyll's custom data capability, to efficiently set various values for narrative text in an IG's markdown files.
In the ig.json / old template arrangement, this was easily done by adding a folder "./pages/_data" alongside the "./pages/_includes" folder with (eg) yaml files containing static narrative values; eg a file "ig-config.yml" with
static_text: "text goes here"
Then if this text is required across multiple markdown files, we can add {{ site.data.ig-config.static_text }}
into whichever markdown files and the "text goes here" gets populated accordingly.
However, looking into the new IG template approach (using IGP v1.0.70 and custom template that inherits from https://github.com/HL7/ig-template-base), I have not figured out how this can be done. I have added a "_data" folder with a yml file (with above details) into various locations and nothing yet seems to work. That is, adding into the input IG rather than the template IG, into "./input", "./input/includes", "./input/pagecontent" - all have no impact. As does a json file instead.
Just wondering if this capability is available with the new template approach - and if so, any clues as to how would I get it to work?
Lloyd McKenzie (Mar 09 2020 at 15:58):
It's not something built in right now. it's something we could potentially add support for (or you could do it with a custom template that inherits from the base). Do you want to create a Git issue against the base template?
Rob Eastwood (Mar 09 2020 at 22:21):
Lloyd McKenzie said:
It's not something built in right now. it's something we could potentially add support for (or you could do it with a custom template that inherits from the base). Do you want to create a Git issue against the base template?
Thank you very much @Lloyd McKenzie - I'll have a tinker with our custom template as well as creating a git issue, as suggested.
Jose Costa Teixeira (Jul 21 2020 at 10:52):
what would be the location for a jekyll data file in both those scenarios?
- in the template
- for one IG
Lloyd McKenzie (Jul 21 2020 at 14:36):
The template would have to decide on an appropriate folder and copy whatever was in it to temp/pages/_data
Lloyd McKenzie (Jul 21 2020 at 14:36):
My leaning for a folder name would be 'data'
Jose Costa Teixeira (Jul 21 2020 at 14:38):
:) indeed i created a folder called "data" - from your answer the template does not have the feature to copy that over to the temp folder. Should I add this to ant.xml?
Lloyd McKenzie (Jul 21 2020 at 15:04):
y. From both template/data and input/data. Not sure if we have to pass the filenames in or not
Jose Costa Teixeira (Jul 21 2020 at 15:11):
i'd copy the whole folder, recursively.
Jose Costa Teixeira (Jul 21 2020 at 15:16):
start with template, then add input (allows input to override template).
Eric Haas (Jul 21 2020 at 15:28):
@Rob Eastwood you can add custom variables to your IG put your yaml, or json or csv file in the input/data folder. like so...
image.png
Eric Haas (Jul 21 2020 at 15:31):
you can retrieve these variable using for example {{site.data.,my_params.title}} for example.
Unfortunately, you can't use _config.yaml directly.
Eric Haas (Jul 21 2020 at 15:35):
you can also add custom params into the ig resource
definition:
parameter:
- code: foo
value: bar
but I think the only way you can access them is via the method described above.
Eric Haas (Jul 21 2020 at 15:38):
you can even stick you resources in here and manipulate the elements directly as variables
Rob Eastwood (Jul 22 2020 at 08:11):
Eric Haas said:
you can retrieve these variable using for example {{site.data.,my_params.title}} for example.
Great, thanks @Eric Haas - that works for me; much appreciated.
Rob Eastwood (Jul 22 2020 at 08:24):
Eric Haas said:
you can also add custom params into the ig resource
...
but I think the only way you can access them is via the method described above.
@Eric Haas - I have been making use of some of the standard ImplementationGuide resource parameters, but had not come across adding custom ones. Not sure what you mean by "method described above" though - is it via the ant.xml mentioned by Jose? Or something else? Any pointers in that direction would be appreciated.
Rob Eastwood (Jul 22 2020 at 08:27):
Eric Haas said:
you can even stick you resources in here and manipulate the elements directly as variables
@Eric Haas - this sounds most interesting, however I must confess to not understanding what you mean here. Do you have a shareable working example that I could examine?
Thank you very much for your time.
Jose Costa Teixeira (Jul 22 2020 at 08:38):
what Eric means is that since FHIR resources are json files, nothing prevents you from throwing them in the data folder and read it as a variable file
Rob Eastwood (Jul 22 2020 at 09:59):
Jose Costa Teixeira said:
what Eric means is that since FHIR resources are json files, nothing prevents you from throwing them in the data folder and read it as a variable file
Thank you @Jose Costa Teixeira - ahh yes makes sense, although we would need to shift away from xml resources, which is our local pattern. That aside, the option is available - thanks for pointing that out.
Lloyd McKenzie (Jul 22 2020 at 14:23):
The IG Publisher will generate JSON for your XML. You'd just have to supplement the standard publisher script to copy your JSON files to the _data folder. We could potentially even do that as part of the standard template...
Jose Costa Teixeira (Jul 22 2020 at 14:45):
Adding all resources as data?
Lloyd McKenzie (Jul 22 2020 at 16:24):
Copying them, y
Rob Eastwood (Jul 22 2020 at 21:34):
Lloyd McKenzie said:
The IG Publisher will generate JSON for your XML. You'd just have to supplement the standard publisher script to copy your JSON files to the _data folder. We could potentially even do that as part of the standard template...
Thanks @Lloyd McKenzie - of course, I had forgotten about the generated JSON. Re copying JSON resources into data via the standard template - if no-one else is wanting this, then I'd say hold off; I'm just exploring options at present rather than having a specific use in mind.
And re "supplementing the standard publisher script" idea - I haven't yet explored this option and have been struggling to find a starting point. I am familiar with some forms of scripting outside of the FHIR toolchain (ruby, bash...) but not ant and its integration with IG Publisher. Are there any good resources for someone getting started with custom scripting for IG Publisher? I have poked around here and devdays videos and not yet come up with anything.
And thanks again to all of you - such a rich melting pot of ideas; its very invigorating
Lloyd McKenzie (Jul 22 2020 at 22:49):
Not much documentation on Jira ant scripts yet, though there is some in the http://github.com/fhir/ig-guidance ig. Other than that, it's asking questions of myself or @Jose Costa Teixeira.
Rob Eastwood (Jul 23 2020 at 09:32):
Thanks @Lloyd McKenzie
Last updated: Apr 12 2022 at 19:14 UTC