-
Notifications
You must be signed in to change notification settings - Fork 169
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
Wrap items in for loop with "PyIsh" equivalents #202
Conversation
Codecov Report
@@ Coverage Diff @@
## master #202 +/- ##
===========================================
+ Coverage 71.24% 71.3% +0.06%
- Complexity 1348 1351 +3
===========================================
Files 215 215
Lines 4278 4280 +2
Branches 682 682
===========================================
+ Hits 3048 3052 +4
+ Misses 988 986 -2
Partials 242 242
Continue to review full report at Codecov.
|
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.
Not terribly familiar with all the implications here but seems safe enough to me
public void testForLoopWithDates() { | ||
Map<String, Object> context = Maps.newHashMap(); | ||
Date testDate = new Date(); | ||
context.put("the_list", Lists.newArrayList(new Date())); |
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.
I think you want to use testDate
when initializing the_list
right?
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.
Yep, good catch. I guess this test worked anyway, because PyishDates aren't that precise? (toString
only prints out to seconds, not millis).
@@ -129,6 +130,7 @@ public String interpret(TagNode tagNode, JinjavaInterpreter interpreter) { | |||
LengthLimitingStringBuilder buff = new LengthLimitingStringBuilder(interpreter.getConfig().getMaxOutputSize()); | |||
while (loop.hasNext()) { | |||
Object val = loop.next(); | |||
val = interpreter.resolveProperty(val, Collections.emptyList()); |
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.
I see what you're trying to do here, but it's weird to call resolveProperty
with an empty list of properties to resolve. Perhaps it would make more sense just to add a delegate method in JinjavaInterpreter
for wrap
.
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.
👍 updated
…so that it can be accessed by tags.
The
wrap
code inJinjavaInterpreterResolver
, wraps objects in theirPyish*
counterparts. However, if the value being wrapped was a list, the children of that value were not wrapped. This resulted in Date values being treated differently if they appeared as a single value or in a list.My initial attempt was modify the list to wrap the children in the
wrap
method, but that resulted in issues modifying the list later on usingset
andappend
functions.