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

Array helper: concat #330

Open ericcornelissen opened 6 years ago

ericcornelissen commented 6 years ago

Hey, awesome project. I just wanted to ask if anyone besides me is interested in a concat helper for arrays (and possibly other types as well, such as strings?). If so I would be interested in creating a PR for that.

Since I'm already using this helper myself, here is the code for it:

module.exports = function(arrayA, arrayB, options) {
  if (Array.isArray(arrayA) && !Array.isArray(arrayB)) {
    return arrayA;
  } else if (Array.isArray(arrayA) && Array.isArray(arrayB)) {
    return arrayA.concat(arrayB);
  } else {
    return [];
  }
}
doowb commented 6 years ago

Thanks for the issue! A PR would be great and we can discuss any details in there.

Thanks!