Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support easier creation of tags with tag helper functions #11

Open
oberhamsi opened this issue Feb 27, 2014 · 1 comment
Open

support easier creation of tags with tag helper functions #11

oberhamsi opened this issue Feb 27, 2014 · 1 comment

Comments

@oberhamsi
Copy link
Contributor

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:

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.

@oberhamsi
Copy link
Contributor Author

angularjs does the same function signature parsing. get their regex & logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant