aurelia-kendoui-bridge
Version:
A set of Telerik KendoUI wrappers for Aurelia allowing developers to easily use KendoUI components in their Aurelia application.
34 lines (30 loc) • 1.28 kB
JavaScript
import {inject} from 'aurelia-dependency-injection';
import {customElement, bindable, noView, processContent, TargetInstruction} from 'aurelia-templating';
import {constants} from '../common/constants';
(`${constants.elementPrefix}template`)
()
((compiler, resources, element, instruction) => {
let html = element.innerHTML;
if (html !== '') {
// if there's a script tag in the template, take the innerHTML of the script tag
// https://github.com/aurelia-ui-toolkits/aurelia-kendoui-bridge/issues/580
let script = kendo.jQuery(element).children('script');
if (script.length > 0) {
instruction.template = kendo.jQuery(script).html();
} else {
// no script tags? the template is the innerHTML
instruction.template = html;
}
}
element.innerHTML = ''; // remove any HTML from `<ak-template>` because it has already been retrieved above
// don't return true, so aurelia does not process the content of <ak-template>
})
(TargetInstruction)
export class Template {
template;
for = 'template';
kendoTemplate = false;
constructor(targetInstruction) {
this.template = targetInstruction.elementInstruction.template;
}
}