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

Upgrade to tagalong v2 #1530

Open
shawnbot opened this issue Jun 17, 2016 · 0 comments
Open

Upgrade to tagalong v2 #1530

shawnbot opened this issue Jun 17, 2016 · 0 comments

Comments

@shawnbot
Copy link
Contributor

The site currently uses a very old (pre-v1) version of tagalong. v2 solves a bunch of the issues that the site works around in various ways, but also has an entirely different API:

  • In v0, the data "context" was referred to as a set of "directives" that are bound to and called with the data. (For instance this element's data-bind attribute refers to this directive.) In v1 and later, this relationship is not explicit: expressions are evaluated on either the context or the data—whichever matches the expression.
  • In v0, the data "directives" were all interpolated immediately and applied to specific nodes, which meant that we needed to render data to each section individually rather than just rendering the outermost template element, which is the norm in v2.

These differences will necessitate a rewrite of most of either the JavaScript or the HTML. There are two ways that we could go about it:

  1. Update only the HTML, replacing data-bind and class attributes with more explicit tagalong expressions. E.g. data-bind="size_number" would become t-text="(d) => size_number(d)".

  2. Rename the data-bind attributes to the corresponding t- attributes, and modify the JavaScript to pass "proxies" to tagalong.render() that evaluate similarly named properties like size_number in the context of specific data elements. With some slight modifications to picc.school.directives, we could do this with object-surrogate:

    var surrogate = require('object-surrogate');
    tagalong.render('#school', surrogate(school, picc.school.directives));

In either case, v0-style "directives" that set text or attributes of child elements would need to be migrated to the HTML, since v1 and later removes support for these and shifts all responsibility for defining template logic to the HTML.

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

Successfully merging a pull request may close this issue.

2 participants