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.
|
nbelisle11
left a comment
There was a problem hiding this comment.
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.
I think you want to use testDate when initializing the_list right?
There was a problem hiding this comment.
Yep, good catch. I guess this test worked anyway, because PyishDates aren't that precise? (toString only prints out to seconds, not millis).
| 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.
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.
…so that it can be accessed by tags.
The
wrapcode 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
wrapmethod, but that resulted in issues modifying the list later on usingsetandappendfunctions.