Humm. To the question is do we want to expose the template as a first order
object or treat it as a simple config?

It almost feels like you are getting too creative if you are trying to hit
the template outside of the render cycles. Is this a fair assessment? (This
is ignoring possible impact on the existing code right now, just "ideal
api")


On Fri, Feb 8, 2013 at 6:06 PM, Ryan Eastridge <notifications@github.com>wrote:

> In src/thorax.js:
>
> > @@ -64,13 +64,11 @@ Thorax.View = Backbone.View.extend({
> >      // Setup helpers
> >      bindHelpers.call(this);
> >
> > -    //compile a string if it is set as this.template
> > -    if (typeof this.template === 'string') {
> > -      this.template = Handlebars.compile(this.template, {data: true});
> > -    } else if (this.name && !this.template) {
> > -      //fetch the template
> > -      this.template = Thorax.Util.getTemplate(this.name, true);
> > -    }
> > +    // template isn't required unless render is called
> > +    // will do a second check there
> > +    assignTemplate.call(this, 'template', {
> > +      required: false
>
> Removing this block still allows all thorax UTs to pass but I worried
> about impact on phoenix and asda. Idea was that after the view was
> initialized but before it was rendered you might work with the template.
>
> var view = new View({
>   name: 'my-name',
>   someMethod: function() {
>     // do something special with template
>     var output = this.template({});
>   }
> });
> view.someMethod(); //raises
> view.render();
> view.someMethod(); //won't raise
>
> Grepped in asda and phoenix, didn't find any usage of that pattern but
> wanted to be on the safe side.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/walmartlabs/thorax/pull/113/files#r2951551>..
>
>