helpers / handlebars-helpers

188 handlebars helpers in ~20 categories. Can be used with Assemble, Ghost, YUI, express.js etc.
http://assemble.io/helpers/
MIT License
2.22k stars 364 forks source link

pick #326

Closed jw-miaem closed 6 years ago

jw-miaem commented 6 years ago

Hi, I cant seem to get pick to work with array of values. This is what I'm trying and possibly have incorrect format: {{#pick ['progressTitle','pageTitle'] health.signup.company-registration}}

doowb commented 6 years ago

Handlesbars doesn't accept literal array syntax in the templates, so you'll need to put the array of properties on the data context, then pass that variable in:

const data = {
  props: ['progressTitle', 'pageTitle'],
  health: {
    signup: {
      company-registration: {
        progressTitle: 'Foo',
        pageTitle: 'Page foo'
      }
    }
  }
};

Handlebars.compile('{{#pick props health.signup.company-registration}}{{/pick}}')(data);

I hope this helps.

jw-miaem commented 6 years ago

Thanks for help