Skip to content

Method-calling filter for use in Jinja's map filter.#50152

Merged
rallytime merged 3 commits intosaltstack:developfrom
zer0def:method-call-jinja-filter
Oct 23, 2018
Merged

Method-calling filter for use in Jinja's map filter.#50152
rallytime merged 3 commits intosaltstack:developfrom
zer0def:method-call-jinja-filter

Conversation

@zer0def
Copy link
Copy Markdown
Contributor

@zer0def zer0def commented Oct 21, 2018

What does this PR do?

The purpose of this PR is to introduce a method_call Jinja filter which by itself doesn't expose new functionality, but when carefully used with other filters, like map(), can lead to significant reduction in templating boilerplate.

@zer0def
Copy link
Copy Markdown
Contributor Author

zer0def commented Oct 21, 2018

I'm also aware that returning None on a missing object method isn't the cleanest or most sane of ways to handle this exception and I need to evaluate better handling.

@zer0def zer0def changed the title Method-calling filter for use in Jinja's map filter. [WIP] Method-calling filter for use in Jinja's map filter. Oct 21, 2018
Copy link
Copy Markdown
Contributor

@gtmanfred gtmanfred left a comment

Choose a reason for hiding this comment

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

.

Copy link
Copy Markdown
Contributor

@gtmanfred gtmanfred left a comment

Choose a reason for hiding this comment

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

lgtm

@zer0def zer0def changed the title [WIP] Method-calling filter for use in Jinja's map filter. Method-calling filter for use in Jinja's map filter. Oct 22, 2018
Copy link
Copy Markdown
Contributor

@cachedout cachedout left a comment

Choose a reason for hiding this comment

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

This is clever. I like it.

@zer0def
Copy link
Copy Markdown
Contributor Author

zer0def commented Oct 22, 2018

Clever until someone stubs their toe on methods mutating values in-place and returning None.

Copy link
Copy Markdown
Contributor

@rallytime rallytime left a comment

Choose a reason for hiding this comment

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

One quick change is needed from me. The develop branch is currently code-named Neon.

Comment thread doc/topics/jinja/index.rst Outdated
``method_call``
---------------

.. versionadded:: develop
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
.. versionadded:: develop
.. versionadded:: Neon

@cachedout
Copy link
Copy Markdown
Contributor

@rallytime I just went ahead and changed it if you would like to re-review this, please.

@rallytime rallytime merged commit a953c70 into saltstack:develop Oct 23, 2018
@s0undt3ch s0undt3ch mentioned this pull request Apr 21, 2020
1 task
@s0undt3ch
Copy link
Copy Markdown
Contributor

Port to master #56765

@s0undt3ch s0undt3ch added the has master-port port to master has been created label Apr 21, 2020
dwoz added a commit that referenced this pull request Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-jam has master-port port to master has been created

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants