Skip to content

Commit

Permalink
Fixing bug for helpers inside of each and else blocks. Fixes SlexAxto…
Browse files Browse the repository at this point in the history
  • Loading branch information
SlexAxton committed Oct 16, 2012
1 parent a4fe07a commit c3cbd08
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Handlebars : `v1.0.rc.1`

hbs.js : `v0.3.2`
hbs.js : `v0.3.3`

## Requirements

Expand Down
3 changes: 2 additions & 1 deletion demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ define(['hbs!template/one'], function (tmplOne) {
var container = document.getElementById('demo-app-container');
// Run your template function, and inject it.
container.innerHTML = tmplOne({
adjective : 'favorite'
adjective : 'favorite',
listofstuff : ['bananas', 'democracy', 'expired milk']
});
});
18 changes: 16 additions & 2 deletions demo/template/one.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@
}
}}
<div class="best class ever">
This plugin is my {{ adjective }} plugin ever.

{{! Do a little bit of unecessary logic in here
to show that it works with block helpers
and iterators }}

{{#if "1"}}
This plugin is my {{ adjective }} plugin ever.
{{/if}}
<br />
<br />

Seriously, {{yeller adjective}}
{{#each listofstuff}}
{{#if doesntexist}}
cant get here
{{else}}
{{yeller .}}
<br />
{{/if}}
{{/each}}
<br />

{{> template_coolPartial }}
Expand Down
5 changes: 4 additions & 1 deletion hbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ define([
res.push(prefix + statement.id.string);
}

var paramsWithoutParts = ['this', '.', '..'];
var paramsWithoutParts = ['this', '.', '..', './..', '../..', '../../..'];

// grab the params
if ( statement.params ) {
Expand Down Expand Up @@ -252,6 +252,9 @@ define([
// if it's a whole new program
if ( statement && statement.program && statement.program.statements ) {
sideways = recursiveVarSearch([statement.mustache],[], "", helpersres)[0] || "";
if ( statement.program.inverse && statement.program.inverse.statements ) {
recursiveVarSearch( statement.program.inverse.statements, res, prefix + newprefix + (sideways ? (prefix+newprefix) ? "."+sideways : sideways : ""), helpersres);
}
recursiveVarSearch( statement.program.statements, res, prefix + newprefix + (sideways ? (prefix+newprefix) ? "."+sideways : sideways : ""), helpersres);
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "require-handlebars-plugin",
"version": "0.3.2",
"version": "0.3.3",
"author": "Alex Sexton <alexsexton@gmail.com>",
"description": "A plugin for handlebars in require.js",
"repository": {
Expand Down

0 comments on commit c3cbd08

Please sign in to comment.