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 simple_test for custom test extensions #1871
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Kurt McKee <contactme@kurtmckee.org>
Co-authored-by: Kurt McKee <contactme@kurtmckee.org>
All the corrections have been done, would it be possible to get this reviewed again :-) Thank you. :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Kurt McKee <contactme@kurtmckee.org>
""" | ||
Register a function for use as a test extension for Jinja templates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think flake8 is upset with this:
""" | |
Register a function for use as a test extension for Jinja templates. | |
"""Register a function for use as a test extension for Jinja templates. |
""" | ||
Register a function for use as a filter extension for Jinja templates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think flake8 is upset with this:
""" | |
Register a function for use as a filter extension for Jinja templates. | |
"""Register a function for use as a filter extension for Jinja templates. |
|
||
This decorator allows creation of a filter extension to Jinja as a function | ||
instead of writing a full class extending jinja2's Extension. The function | ||
name becomes the filter name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name becomes the filter name | |
name becomes the filter name. |
@simple_test | ||
def mirror(value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be rendered in the API documentation. This should be a more complete example, including RST syntax:
@simple_test | |
def mirror(value): | |
.. codeblock:: python | |
@simple_test | |
def mirror(value): | |
return value[::-1] |
This suggestion applies to the code changes lower in this file, too.
|
||
Which can then be used in jinja template as | ||
|
||
{{ cookiecutter.param | mirror }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a codeblock so that it renders in the API documentation. I don't think pygments has a Jinja lexer specifically, so I'm suggesting text
here to avoid incorrect syntax highlighting:
{{ cookiecutter.param | mirror }} | |
.. codeblock:: text | |
{{ cookiecutter.param | mirror }} |
This suggestion applies to the code changes lower in this file, too.
Currently there is a decorator to create a simple filter Jinja extension. This PR adds a similar decorator to create custom test extensions. Included is the decorator, test updatres, and docs updates