Passing key/value pairs as data in routes?

Is it possible to pass key/value pairs as data to a template in a custom route?

Essentially, this sort of thing (but this doesn’t work):

        template: welcome
          foo: bar

Thus in the template, {{foo}} renders to bar?


Hey @Jeremy606 :wave:

You can’t do something like that at the moment. Do you mind sharing what you’re trying to do?

1 Like

I really wish you could but I don’t think it’s possible.

Thanks, guys. @vikaspotluri123, basically we are trying to abuse Ghost and perhaps make it something it is not. :slight_smile:

We are using Ghost to deliver educational content for remote learning during the COVID-19 isolation. We use tags to associate posts with a given “class” as well as a specific audience group. (Basically, you could think of classes as having different sections-- some posts are all sections of a class, some for only specific sections).

We’ve made this work by creating a custom route and template for each combination of class+section. If we could have passed parameters to routes, this would have eliminated the need to create so many template files-- instead we could have just use one parameterized template.

Thanks for the help!

1 Like