{"id":8083,"date":"2015-11-25T19:32:24","date_gmt":"2015-11-25T19:32:24","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/25\/how-to-use-multiple-parameters-in-a-handlebar-helper-with-meteor-open-source-projects-meteor-meteor\/"},"modified":"2022-08-30T15:03:02","modified_gmt":"2022-08-30T15:03:02","slug":"how-to-use-multiple-parameters-in-a-handlebar-helper-with-meteor-open-source-projects-meteor-meteor","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/25\/how-to-use-multiple-parameters-in-a-handlebar-helper-with-meteor-open-source-projects-meteor-meteor\/","title":{"rendered":"How to use multiple parameters in a handlebar helper with meteor?-open source projects meteor\/meteor"},"content":{"rendered":"<p>I am trying to create a custom helper using Meteor. Following to the doc here: https:\/\/github.com\/meteor\/meteor\/wiki\/Handlebars<\/p>\n<p>I have tried to define my helper as follows:<\/p>\n<pre><code>Template.myTemplate.testHelper = function(foo, bar, options) {\n    console.log(foo);\n    console.log(bar);\n}\n<\/code><\/pre>\n<p>My template looks like:<\/p>\n<pre><code>\n    {{#testHelper \"value1\" \"value2\"}}\n    {{\/testHelper}}\n\n<\/code><\/pre>\n<p>Looking at my console output, I expected to see 2 lines of output:<\/p>\n<pre><code>value1\nvalue2\n<\/code><\/pre>\n<p>However my console looks like:<\/p>\n<pre><code>value1\nfunction (data) {\n    \/\/ don't create spurious annotations when data is same\n    \/\/ as before (or when transitioning between e.g. `window` and\n    \/\/ `undefined`)\n    if ((data || Handlebars._defaultThis) ===\n        (old_data || Handlebars._defaultThis))\n      return fn(data);\n    else\n      return Spark.setDataContext(data, fn(data));\n  } \n<\/code><\/pre>\n<p>Note, I am completely new to meteor, and to handlebars. I think I would be much happier using underscore, but the documentation for meteor glances over underscore almost entirely. Am I doing something wrong defining my helper function? It seems that it is not seeing the second parameter &#8220;bar&#8221;, and instead interpreting that as the options. (Note: if I console.log(options) it returns &#8216;undefined&#8217;).<\/p>\n<p>Meteor version 0.4.0 (8f4045c1b9)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am trying to create a custom helper using Meteor. Following to the doc here: https:\/\/github.com\/meteor\/meteor\/wiki\/Handlebars I have tried to define my helper as follows: Template.myTemplate.testHelper = function(foo, bar, options) { console.log(foo); console.log(bar); } My template looks like: {{#testHelper &#8220;value1&#8221; &#8220;value2&#8221;}} {{\/testHelper}} Looking at my console output, I expected to see 2 lines of output: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8083","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8083"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8083\/revisions"}],"predecessor-version":[{"id":8639,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8083\/revisions\/8639"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}