Support for rendering document fragments (returned from the renderer function) in the templates #244

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants
@retro
Contributor

retro commented Jan 19, 2013

This change allows passing of document fragments directly to the template layer. They are live bound as they are never converted to the string. It allows syntax that looks like this:

var renderer = can.view.mustache('<b>{{{ subview }}}</b>');
var subview = can.view.mustache('Subview {{ foo }}');
var foo = can.compute("FOO")
var div = document.createElement('div');
div.appendChild(renderer({
    subview : function(){
        return subview({
            foo : foo
        })
    }
}));

div.innerHTML // <b>Subview FOO</b>

foo("BAR")

div.innerHTML // <b>Subview BAR</b>    
Implement support for rendering document fragments returned from the …
…renderer function in the Mustache and EJS templates
@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Jan 19, 2013

Contributor

Problem is, what if they try to insert the same template twice.

Sent from my iPhone

On Jan 19, 2013, at 7:02 AM, Mihael Konjević notifications@github.com wrote:

This change allows passing of document fragments directly to the template layer. They are live bound as they are never converted to the string. It allows syntax that looks like this:

var renderer = can.view.mustache('{{{ subview }}}');
var subview = can.view.mustache('Subview {{ foo }}');
var foo = can.compute("FOO")
var div = document.createElement('div');
div.appendChild(renderer({
subview : function(){
return subview({
foo : foo
})
}
}));

div.innerHTML // Subview FOO

foo("BAR")

div.innerHTML // Subview BAR
You can merge this Pull Request by running

git pull https://github.com/bitovi/canjs render_fragments_in_templates
Or view, comment on, or merge it at:

#244

Commit Summary

Implement support for rendering document fragments returned from the renderer function in the Mustache and EJS templates
File Changes

M view/view.js (6)
M view/view_test.js (34)
Patch Links:

https://github.com/bitovi/canjs/pull/244.patch
https://github.com/bitovi/canjs/pull/244.diff

Contributor

justinbmeyer commented Jan 19, 2013

Problem is, what if they try to insert the same template twice.

Sent from my iPhone

On Jan 19, 2013, at 7:02 AM, Mihael Konjević notifications@github.com wrote:

This change allows passing of document fragments directly to the template layer. They are live bound as they are never converted to the string. It allows syntax that looks like this:

var renderer = can.view.mustache('{{{ subview }}}');
var subview = can.view.mustache('Subview {{ foo }}');
var foo = can.compute("FOO")
var div = document.createElement('div');
div.appendChild(renderer({
subview : function(){
return subview({
foo : foo
})
}
}));

div.innerHTML // Subview FOO

foo("BAR")

div.innerHTML // Subview BAR
You can merge this Pull Request by running

git pull https://github.com/bitovi/canjs render_fragments_in_templates
Or view, comment on, or merge it at:

#244

Commit Summary

Implement support for rendering document fragments returned from the renderer function in the Mustache and EJS templates
File Changes

M view/view.js (6)
M view/view_test.js (34)
Patch Links:

https://github.com/bitovi/canjs/pull/244.patch
https://github.com/bitovi/canjs/pull/244.diff

@retro

This comment has been minimized.

Show comment
Hide comment
@retro

retro Jan 19, 2013

Contributor

What is the exact problem? Renderer function will return new documentFragment each time it's called so it will have unique data-view-id and a new hook.

What is the preferred behavior?

Contributor

retro commented Jan 19, 2013

What is the exact problem? Renderer function will return new documentFragment each time it's called so it will have unique data-view-id and a new hook.

What is the preferred behavior?

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Jan 23, 2013

Contributor

Is it supposed to work?

Contributor

whitecolor commented Jan 23, 2013

Is it supposed to work?

@retro

This comment has been minimized.

Show comment
Hide comment
@retro

retro Jan 23, 2013

Contributor

There are some issues that I have to iron out before this could be merged to the main repo. But, it seems to be working with mustache pretty good so far.

Contributor

retro commented Jan 23, 2013

There are some issues that I have to iron out before this could be merged to the main repo. But, it seems to be working with mustache pretty good so far.

@ghost ghost assigned retro Jan 25, 2013

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Mar 12, 2013

Contributor

Any news on this? Could you updated your branch and submit a new pull request targeted for the develop branch (1.2)?

Contributor

daffl commented Mar 12, 2013

Any news on this? Could you updated your branch and submit a new pull request targeted for the develop branch (1.2)?

@daffl daffl closed this Mar 12, 2013

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Mar 24, 2013

Contributor

Does this work? In what version?

Contributor

whitecolor commented Mar 24, 2013

Does this work? In what version?

@daffl daffl deleted the render_fragments_in_templates branch Oct 22, 2015

@retro retro removed their assignment Oct 29, 2015

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