Load dynamic content macro editor pop up window by overriding opener function

Hi Team,

I’m trying to override the macro editor pop up window by using soy template. I tried to override the opener function of AJS.MacroBrowser.setMacroJsOverride. I’m getting error saying “.customform” [my soy template name] is not found.

<--------------custom.js file ------------------->

AJS.bind('init.rte', function() {
    AJS.MacroBrowser.setMacroJsOverride('sample-link', {opener:
        function(macro) {
           // window.alert('PUT your JS in this function');
           var template=Confluence.Templates.Soycustomdialog.customform;
           $("body").append(template);
           AJS.dialog2("#sample-macro-dialog").show();

		tinymce.confluence.MacroUtils.insertMacro({
			contentId: Confluence.Editor.getContentId(),
			macro: {
				name: "sample-link",
				params: {
					search: "abcd",
					placeholder: "efgh"
				},
				defaultParameterValue: "",
				body: undefined
			}
		}, macro);

        }
    });

Configuration in .xml file

 <web-resource key="insert-link-javascript" name="Insert Link Dialog JavaScript">
        <!-- transform calls to AJS.getText() inside JS files -->
        transformation extension="js">
            transformer key="jsI18n"/>
        /transformation>

        <!-- transform Soy templates into JS -->
        <transformation extension="soy">
            <transformer key="soyTransformer">
                <functions>com.atlassian.confluence.plugins.soy:soy-core-functions</functions>
            </transformer>
        </transformation>

        <!-- JavaScript resources -->
        <resource name="custom.js" type="download" location="js/custom.js"/>
        <resource name="template.soy" type="download" location="js/template.soy"/>

        <!-- we need the editor resources to be loaded before these ones -->
        <dependency>com.atlassian.confluence.tinymceplugin:editor-javascript-resources</dependency>

        <!-- these resources will be included with any page containing the editor -->
        <context>editor</context>
    </web-resource>

I’ve attached snapshot of template.soy file as code is getting converted to html form while pasting it in the question.

Thanks

Hi Team,

Could anyone please tell me what is the issue over here ? I did not find anything to resolve it .