Reactive Templates - Create overridable templates

Hi,

I wan’t everyone to meet nicolaslopezj:reactive-templates.

This allows meteor package authors (and anyone) to make their templates overridable.

More specifically, what this packages does is that allows you to work a “imaginary template” where you can set helpers, events, use it in some routes, etc. then, you can assign that “imaginary template” to a “real template” and all the helpers, events, etc. will be assigned to that “real template” and the route will be re-rendered.

Here is the github repository with the documentation and a example

I hope everyone can contribute with ideas, implement new features and help with the documentation.

1 Like

to borrow from OOP world, is that an abstract (class) template?

Its more simple than that. What you do is that you assign helpers, events, etc.

ReactiveTemplates.request('myIdentifier')

ReactiveTemplates.helpers('myIdentifier', {
  getTitle: function() {
    return 'My Title'
  }
})

ReactiveTemplates.onRendered('myIdentifier', function() {
  alert('Hi!')
})

Maybe we can use that future template

Router.route('/my-path', function () {
  this.layout(ReactiveTemplates.get('layout'));
  this.render(ReactiveTemplates.get('myIdentifier'));
});

And after that (or before) someone assigns a template

ReactiveTemplates.set('myIdentifier', 'myTemplate')

Now the template its re-rendered automatically because of the reactivity and “myTemplate” has now the helpers and hooks we defined

This is useful to package authors, to leave the possibility to the developer to change the template after.

Do you have a Meteor Pad example you can share to see this in use?

I can’t right know because the package does not appear in the list of packages, maybe because its new.
I will create one soon!