foo.changed vs foo|changed

It’s unfortunately exceedingly difficult to search for “|” in most search engines, so finding info about this was not fruitful.

My question is, is there a difference between foo.changed and foo|changed, especially used in a “when:” parameter?

If there’s no difference, what’s the preferred syntax?

Thanks!

There is a difference, in fact the preferred syntax is actually when: foo is changed

There is no guarantee that the attribute will exist on a returned object. In addition to handling a non existent key/attribute, the changed test also has some more complex logic, where it will look into a sub-key called results too.

Historically we did not have jinja tests, which is what the foo is changed represents, so we registered them as filters (foo|changed). We are deprecating using tests as filters, which is why the is syntax is preferred there.

Thanks for the full and complete answer!