allow optional use of a filter based on its existence#1248
allow optional use of a filter based on its existence#1248davidism merged 1 commit intopallets:masterfrom
Conversation
596c7d0 to
72c9b1b
Compare
b0d2890 to
a127d9f
Compare
c0fb589 to
541bf72
Compare
|
Are we covering cases like |
Right, I forgot to account for those but probably should (and will) too. |
|
I have the feeling any block-level check is likely to have problematic edge cases - can't we just let it fail when actually accessing the filter? |
Hmm that's true. The error won't be as helpful though: |
|
Good point, that error is awful and filters that are sometimes but not always undefined are very much an edge case for which we probably shouldn't sacrifice error verboseness with other, more common, cases |
|
Could we compile filters to something like this at the beginning of the template? try:
filter_tmp_0 = self.filters['filter_name']
except KeyError:
@internalcode
def filter_tmp_0(*unused):
raise TemplateRuntimeError("no filter named 'filter_name'")Then the code where the filter is actually used just uses |
|
Ooh that's a good idea! I moved it to |
|
I'm working on a separate PR to create an |
Resolves #842
Files changed:
nodes.pycompiler.pyruntime.py