Skip to content

Using one JSON file as a data source for two templates #3872

Answered by dwkns
2inchesofwater asked this question in General
Discussion options

You must be logged in to vote

I'm not 100% sure what you're actually trying to achive here, can you give a little more detail. Maybe the contents of your data files? Or an illustration of what is in them.

I might be wrong, but I don't think you can set a key in front-matter to be the contents of a data file. That is why you're struggline with :

Meat Products
category dump: [object Object]

Reading between the lines, you want to avoid having to rewrite your entire template each time you want to move beween meat and veg. Assuming the two json data files share the same strucutre you could do something like this (in Nunjcks):
meat.json

{
  "description": "A collection of meats, each with a unique name and price.",
  "produ…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by 2inchesofwater
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants