mikeric / rivets

Lightweight and powerful data binding.

Home Page:http://rivetsjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Separate scopes / do not pollute global "rivets" configuration

sp00x opened this issue · comments

This may just be something I am not seeing, but is there a way of creating different scopes that do not share the same "rivets" object?

I.e. I do not see a way of having 2 separate views with different formatters bound to them, as they are all registered on the same "rivets" object,

E.g.
rivets.formatters.gt = (a,b) => a > b;
becomes available in all bindings/views, as far as I can tell?

I want isolated views that are not "polluted" with formatters and other options set on other views, as there could be configurations sourced from separate parties on the same page.

E.g. if I could do let scope1 = new rivets(); scoped.formatters.gt = ...

Is this not possible?

Maybe if this was possible to configure on the rivets.bind(el, data, ...local config...) ?

In Handlebars you can do: template({ ..data.. }, { helpers: { gt: (a,b) => a > b })