I'm working on swig.js to make it work with Django more friendly,I can understand most of the codes but the parse.js,I wonder what the 'filterApplyIdx' exactly means.Is there anybody else working on this too?
I'm working on swig.js to make it work with Django more friendly,I can understand most of the codes but the parse.js,I wonder what the 'filterApplyIdx' exactly means.Is there anybody else working on this too?
As I posted to the mailing list
filterApplyIdxis an array of indices on theout(output) array at which filters will be applied. When the parser finds a filter it will apply it to theoutarray at the index of the last value infilterApplyIdx.For example: if the
outarray has the following['(', 'my_var'], thefilterApplyIdxshould be[0, 1]. (it will apply first tomy_var, and second to everything that is encompassed by the opening parenthesis, once the closing parenthesis is found). So, if the next item parsed is a filter, it will pop thefilterApplyIdxlast value, which is1, and look at theoutarray, and apply the filter to the token atout[1].If, however, the
outarray was something more complex, like:['my_func(', 'foo', 'bar'](note that the closing parenthesis formy_funchas not been found yet), thefilterApplyIdxwill be:[0, 2]. We've removed1now because the chance to apply a filter tofoohas passed, since a new variable,barwas found.