Open
Description
In jinja2, you can apply the length filter directly on strings like: {{ my_string | length }}
, this will produce an empty value in jinja2Cpp.
The fix seems to be as simple as changing filters.cpp:457
diff --git a/src/filters.cpp b/src/filters.cpp
--- a/src/filters.cpp
+++ b/src/filters.cpp
@@ -454,7 +454,7 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte
InternalValue result;
bool isConverted = false;
- ListAdapter list = ConvertToList(baseVal, isConverted);
+ ListAdapter list = ConvertToList(baseVal, isConverted, false);
if (!isConverted)
return result;
And adding a test:
diff --git a/test/filters_test.cpp b/test/filters_test.cpp
--- a/test/filters_test.cpp
+++ b/test/filters_test.cpp
@@ -161,6 +161,7 @@ INSTANTIATE_TEST_SUITE_P(Length, FilterGenericTest, ::testing::Values(
InputOutputPair{"intValue | length", ""},
InputOutputPair{"intList | length", "10"},
InputOutputPair{"stringValue | list | length", "4"},
+ InputOutputPair{"stringValue | length", "4"},
InputOutputPair{"reflectedIntVector | length", "10"}
));
Metadata
Metadata
Assignees
Labels
No labels