Template function access to item


Would there be any objection to the possibility of allowing access to the item from plugin template functions, if it’s viable? I know the default template functions have it saved in their object, but this isn’t the case for plugin template functions, and having it would open up a few interesting plugin possibilities.

It’s an interesting question… it seems OK in general, if we can preserve backwards-compatibility so that Python functions in plugins that already exist (i.e., don’t expect an item argument) can still work. It might be a little hard to accomplish, however, because the templating library we use needs to take “plain” functions where the arguments are just the strings in the template, so giving access to the item would require creating a closure for every single template instantiation. So it may be harder (and slower?) than it seems at first…

Maybe it’s worth considering if there’s another way to accomplish the same thing, perhaps by using a field combined with a function? (Maybe you could elaborate a bit on the use case you have in mind?)

Understood. Giving it further thought, I think you’re right, not worth the hassle, I’ll mull over alternatives for now. Thanks.