You cannot follow this path. The first reason is because the editor expects html be a string, not a function. The second reason is because your AJAX request does not make sense, as it is called asynchronously, and return html is executed until the request completes.
In any case, what you want to do is preload your temple (s) as soon as the editor is ready. You can simply modify the following XHR request with jQuery code, but you must remember that you must call CKEDITOR.addTemplates in the success callback:
CKEDITOR.replace( 'editor1', { templates: 'my', on: { instanceReady: function( argument ) { var httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function() { CKEDITOR.addTemplates( 'my', { templates: [ { title: 'My AJAX-driven template', html: this.responseText } ] }); }; httpRequest.open( 'GET', 'yourFile.html' ); httpRequest.send(); } } });
If you really wanted to do it live (difficult, I do not recommend it to you), you should rewrite the templates command with your code, which loads custom templates, and then executes the real command. I don't think you need to do this, though.
Good luck
source share