Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need more information on helper API and context #157

Open
criticalmash opened this issue Jul 15, 2016 · 3 comments
Open

Need more information on helper API and context #157

criticalmash opened this issue Jul 15, 2016 · 3 comments

Comments

@criticalmash
Copy link

I'm trying to write a block helper that uses a lot of options so I'm looking for a detailed description of what get's passed by registerHelper().

I also need to know exactly what options.fn() does and what I can pass to it.

Also, can you add a main menu to the site? I'm never sure I've looked in every corner when searching the docs.

@kub1x
Copy link

kub1x commented Apr 7, 2017

I found this article only to realize it's obsolete as there are not the fn, elseFn functions passed but some options stuff only briefly mentioned in docs =/

I wanted to write a equals helper that would do simple === comparison and otherwise behave like the if so I looked into the sources of the if helper and figured stuff out... but that's not really the kind of workflow one expects.

@nknapp
Copy link
Collaborator

nknapp commented Apr 7, 2017

I think the page http://handlebarsjs.com/block_helpers.html contains pretty much everything about block-helpers that there is to know, but I agree that the site needs some navigation.

What you pass to options.fn() and options.inverse() is the context on which the block runs.
fn() calls the default block. inverse() calls the block after the {{else}}, if there is one.

Have a look at this jsfiddle: https://jsfiddle.net/vva7musq/15/

@kub1x
Copy link

kub1x commented Apr 7, 2017

Ok. I see it now. The problem is, I struggle to deduct any system on the documentation page.

I scanned the page for the helpers, so I clicked to the built-in helpers docs only to find out, there is no info on how to write my own. So I scrolled down to the bottom where there is a API reference. Yaaaay, I thought, there will be everything in a nice order. Well, uh, it is only methods od the hbs object.. and there is registerHelper, but there is not much inf on what is being passed to it... so I suppose there is no docs on writing helpers, let's fill a bug....

The helpers are well hidden under tne button under the blocks section. I understand it now why you call it a block helpers, but it doesn't make sense when you first think about it. I want to know, how to write any helper, then I want to know there are more types of them.

At least you could put the button linking to the docs on helper making into the API site and Built In Helpers sites.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants