Meteor View Manager

Update This package just got mentioned in Meteor weekly 🙂 meteorhacks.com/meteor-weekly-meteor-new-version-10000-github-stars-dynamic-templates.html
Update This package is now BLAZE ready, the new render engine of meteor, therefor there are some syntax changes.


The view-manager package works like the Session object in meteor, but has some handy features. To place a template somewhere, just add the

{{DynamicTemplate placeholder="myKey" context=myData}}

helper somewhere and then call:

View.set('myKey','myTemplateName');

This will render template in its place. You can call

View.set('myKey',false);

to remove it. Additionally you can pass an object to give it data context e.g:
This context will then be merged with the context passed in template (dynamic content overwrites template set context)

View.set('myKey',{
    template: 'myTemplateName'
    context: {
       ...
    }
});

Check out the package on atmosphere.

  • Charles Short

    Hi this is cool. Feels a lot like the RactiveJS.org that Richard Harris started and David Greenspan (Meteor core) is contributing/borrowing from.

  • frozeman

    hi,

    didn’t knew that, thanks. The view-manager is like that, or the same as Session, with some additional methods.

    the difference between Session and the “View” class is that it wont rerun dependencies, when the View.set(…) is called but the value stayed the same (at least i guess Session is always reacting on that).

    Additionally you can pass something like

    View.set('myTemplatePlaceholder', {template: 'myTemplate', data: {somedatacontext...}});

    adn then have somewhere in your template

    {{DynamicTemplate "myTemplatePlaceholder"}}

    Thats the main difference

  • jim

    This feels like the core part of a cms system

  • Kevin O’Hagan

    This is Awesome Fabian! 🙂 can’t wait to get to 1.0 😉