Skip to content

Dynamic output from one template #16

@paintedbicycle

Description

@paintedbicycle

I'm looking for a way to have one of each type of content in my /src/ folder, but perhaps multiple versions in the /dist/ folder. Types could be 'events', 'blog posts', 'people', etc. I only need one version of the template for each of these and the .json file(s) would have the content.

Something like:

events: {
  preHTML: 'src/partials/header.handlebars',
  postHTML: 'src/partials/footer.handlebars',
  template: 'src/events/event.handlebars',
  templateData: 'src/events/*.json',
  output: 'dist/events/event-[data.EventName].html'
}

Where above, there is one event template and perhaps multiple .json files (one per event). But I would need a way to change the output title based on something in the .json file.

Ultimately, I'd prefer to only have one global .json file and then do something like event.eventName but there doesn't seem like a way to output multiple different files based on one template and json file. I thought about declaring each block separately in the gruntfile, but with one template and one json file, there is no way to tell the processor which block to read from the .json file.

Are either of these two approaches possible?

Paul

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions