You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
django has three functions: simpleTag, assignmentTag and inclusionTag, which take a function as an argument, which they use to create a complete Tag class. Basically those three functions relieve you subclassing the Tag class for specific but common use cases. you only need to write the render function and all the rest - parameter parsing, variable resolving with filter support as well as all interaction with the template parser - is handled automatically.
django has three functions: simpleTag, assignmentTag and inclusionTag, which take a function as an argument, which they use to create a complete Tag class. Basically those three functions relieve you subclassing the Tag class for specific but common use cases. you only need to write the
render
function and all the rest - parameter parsing, variable resolving with filter support as well as all interaction with the template parser - is handled automatically.the three use cases support by django are:
https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#assignment-tags
variables – and return a string after doing some processing based solely
on the input arguments and some external information. the SimpleTag helps
with creating those:
https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#howto-custom-template-tags-simple-tags
https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#howto-custom-template-tags-inclusion-tags
I have implemented the SimpleTag and - I think - all helpers required to
implement the other Tags.
unit tests in my branch:
https://github.com/oberhamsi/reinhardt/blob/tag-filter-helpers/test/library/tags.js
A problem I noticed is that in JavaScript we can't support an indefinite number of arguments because I can't detect rest parameters in the function signature yet https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/rest_parameters This means we have to think of a different way to support an unknown number of arguments. Just parsing the function signature isn't going to get us there.
The text was updated successfully, but these errors were encountered: