We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In jinja2, you can apply the length filter directly on strings like: {{ my_string | length }}, this will produce an empty value in jinja2Cpp.
{{ my_string | length }}
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"} ));
The text was updated successfully, but these errors were encountered:
I run the test suit with these changes and it worked.
Sorry, something went wrong.
No branches or pull requests
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
And adding a test:
The text was updated successfully, but these errors were encountered: