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

Добавить фильтр преобразования стоимости, который можно будет использовать в шаблонизаторе jinja2 #1

Closed
zzzkorn opened this issue Nov 23, 2023 · 0 comments · Fixed by #3
Labels
good first issue Good for newcomers

Comments

@zzzkorn
Copy link
Owner

zzzkorn commented Nov 23, 2023

Пример

import jinja2
from docxtpl import DocxTemplate
from russian_cost import strfcost 

context = dict(coast=12.34)
jinja_env = jinja2.Environment()
jinja_env.filters.update(strfcost=strfcost)
doc = DocxTemplate(template_path)
doc.render(context, jinja_env)
doc.save(result_path)

Внутри шаблона

{{coast|strfcost}}
....
{{coast|strfcost('%S %R и на сдачу %p')}}

Так же нужно

  • Добавить в документацию пример нового функционала

  • Написать тесты для фильтра strfcost

@zzzkorn zzzkorn added the good first issue Good for newcomers label Nov 23, 2023
@zzzkorn zzzkorn linked a pull request Feb 9, 2024 that will close this issue
@zzzkorn zzzkorn closed this as completed in #3 Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant