Skip to content

support easier creation of tags with tag helper functions #11

@oberhamsi

Description

@oberhamsi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions