Skip to content
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 center filter #179

Merged
merged 2 commits into from
Nov 2, 2019
Merged

Add center filter #179

merged 2 commits into from
Nov 2, 2019

Conversation

morenol
Copy link
Contributor

@morenol morenol commented Nov 2, 2019

Implemention of the center filter #171

@codecov
Copy link

codecov bot commented Nov 2, 2019

Codecov Report

Merging #179 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #179      +/-   ##
==========================================
+ Coverage   88.77%   88.79%   +0.01%     
==========================================
  Files          69       69              
  Lines        8715     8730      +15     
==========================================
+ Hits         7737     7752      +15     
  Misses        978      978
Impacted Files Coverage Δ
src/filters.h 94.73% <ø> (ø) ⬆️
src/filters.cpp 89.94% <100%> (+0.01%) ⬆️
src/string_converter_filter.cpp 94.35% <100%> (+0.43%) ⬆️
test/filters_test.cpp 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ebe0bf5...baa4ca0. Read the comment docs.

case CenterMode:
result = ApplyStringConverter(baseVal, [this, &context](auto srcStr) -> TargetString {
auto width = ConvertToInt(this->GetArgumentValue("width", context));
auto str = sv_to_string(srcStr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, it should be additional trimming added at this point. Now you doesn't count the spaces which already present at the beginning or at the end of the string,

Copy link
Contributor Author

@morenol morenol Nov 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about that?

I tested this and it seems that it is not trimming those whitespaces:

from jinja2 import Environment

HTML = """
{{ 'x' | center(width=5) }}
{{ '  x' | center(width=5) }}
"""

def print_html_doc():
    print (Environment().from_string(HTML).render())
print_html_doc()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. You're right. Thank you!

@flexferrum flexferrum merged commit 78e0a7c into jinja2cpp:master Nov 2, 2019
@morenol morenol deleted the filters/center branch July 31, 2020 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants