Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save novascreen/8f77e80fc9810da75283 to your computer and use it in GitHub Desktop.
Save novascreen/8f77e80fc9810da75283 to your computer and use it in GitHub Desktop.
Let's you distribute templateNodes to Shadow DOM style insertion points in your knockout components
define(['jquery'], function ($) {
return function (componentInfo) {
var $templateNodes = $(componentInfo.templateNodes)
$(componentInfo.element).find('content[select]').each(function () {
var $placeholder = $(this),
query = $placeholder.attr('select'),
$content = $templateNodes.filter(query)
$templateNodes = $templateNodes.not($content)
$placeholder.replaceWith($content)
})
$(componentInfo.element).find('content').replaceWith($templateNodes)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment