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

Problem running template inside template #17

Open
mattbrailsford opened this issue Sep 9, 2016 · 1 comment
Open

Problem running template inside template #17

mattbrailsford opened this issue Sep 9, 2016 · 1 comment
Assignees

Comments

@mattbrailsford
Copy link

mattbrailsford commented Sep 9, 2016

I've created a template like this:

{{#range 1 10}}
  {{#if @index}},{{/if}}
  {
      // Some json content
  }
{{/range}}

I'm using a custom helper for the "range" tag, which all works fine, however there seems to be a problem with the if statement inside it. Running handlebars, rather than getting a list of object tags separated by a comma, I get a bunch of commas all grouped together, then the list of objects next to them (not comma seperated).

,,,,,,,,,{}{}{}{}{}{}{}{}{}{}

I'm trying to debug in at the moment, but it looks to be down to the fact that at some point, the span renderer for the comma renders against the writer that is in the scope, which is the current outer blocks scope, rather than the writer generated for the range helper, thus all the commas get written to the main writer, then on completion of the helper, all the other objects are written to the writer directly afterwards.

I'm currently getting really confused with the visitor rabbit whole to be able to narrow it down to a specific location, but any help would be greatly appreciated.

@Antaris
Copy link
Collaborator

Antaris commented Sep 16, 2016

Hi @mattbrailsford

Can you share your code for your helper? I'm wondering if it is actually because it is trying to resolve @index but doesn't realise you are creating an enumerable helper. Might need to expand the helper API to allow you to specifiy what the values for @index, @first and @last should be?

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

2 participants