Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

retro
Copy link
Contributor

@retro 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>    

…renderer function in the Mustache and EJS templates
@justinbmeyer
Copy link
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

@retro
Copy link
Contributor Author

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?

@wclr
Copy link
Contributor

wclr commented Jan 23, 2013

Is it supposed to work?

@retro
Copy link
Contributor Author

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
Copy link
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
@wclr
Copy link
Contributor

wclr commented Mar 24, 2013

Does this work? In what version?

@daffl daffl deleted the render_fragments_in_templates branch October 22, 2015 22:56
@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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants