-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add for(integerVal) counting loops #709
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,23 @@ var bindAndRead = function (value) { | |
} | ||
}; | ||
|
||
function forOfInteger(integer, variableName, options) { | ||
var result = []; | ||
for (var i = 0; i < integer; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems there's some indentation inconsistency |
||
var variableScope = {}; | ||
if(variableName !== undefined){ | ||
variableScope[variableName] = i; | ||
} | ||
result.push( | ||
options.fn( options.scope | ||
.add({ index: i }, { special: true }) | ||
.addLetContext(variableScope) ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think we should create a variable?
I sorta think access should be only through There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On second thought, I think it's ok to make |
||
); | ||
} | ||
|
||
return options.stringOnly ? result.join('') : result; | ||
} | ||
|
||
function forOfObject(object, variableName, options){ | ||
var result = []; | ||
canReflect.each(object, function(val, key){ | ||
|
@@ -68,6 +85,9 @@ var forHelper = function(helperOptions) { | |
options = args.pop(), | ||
resolved = bindAndRead(items); | ||
|
||
if(resolved && resolved === Math.floor(resolved)) { | ||
return forOfInteger(resolved, variableName, helperOptions); | ||
} | ||
if(resolved && !canReflect.isListLike(resolved)) { | ||
return forOfObject(resolved,variableName, helperOptions); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably clean up the signature docs, specifically around this part:
I think we should make it more clear what happens if the
expression
evaluates to: