Simulate returning object in helper

Hey, everyone!
I need to make a dynamic list of paraphs (called options) with dynamic text in each one.
I have text.jade:

each option
  p #{this}

If I pass an array of paragraph strings this returns me each paragraph alright. I would also like to pass dynamic values to each paragraph, like:

  • par1: price 100

  • par2: price 200
    And so on.
    I have a paragraphs object, which contains text and price keys. So, ideally, if Meteor would allow to pass objects to Spacebars, I would write:

    each option
    p #{this.text}: price #{this.price}

But that’s not possible unfortunately. So how can I do this?

Update: while writing this q, I’ve been brainwaved that I should dynamically populate an array in option helper and then return it.
A working solution, but not beatiful)
Can anybody come up wit smth else?

The canonical way would be to separate your paragraph block into its separate template and then populate the paragraph template from your helpers or your data context.

<template name="options">
  {{#each option}}

<template name="paragraph">
  <p>{{text}}: {{price}}</p>

What would be the js code?

It would be too arbitrary for me to come up with placeholder code, but if you can share your current template code and its helpers, I’d be happy to suggest a fix.

Actually I was interested if your solution required creating their own helpers for text and price?

If text and price are part of the data context, no.

If not, yes it will require helpers.

So, what you should do is set the data context to the pararaph template.

Could you link me to some tutorial on contexts and stuff? I think, I’m missing smth here… (not this one: - I’m too dense to understand it)

Yep, please take a look at this:

The each option part in our case actually sets the data context so text and price are readily available themselves.

But, as I said, I need to see your overall template/helper code to elaborate.