Hello everyone
I'm trying to reference a template in .soy template file called 'JIRA.Templates.Test' from JS file.
I'm getting the error: Uncaught TypeError:
Cannot read property 'helloWorld' of undefined at q.render
Can you help me?
<web-resource key="my-resources" name="my-web-resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <dependency>com.atlassian.auiplugin:dialog2</dependency> <dependency>com.atlassian.auiplugin:aui-experimental-restfultable</dependency> <dependency>com.atlassian.auiplugin:aui-experimental-soy-templates</dependency> <resource type="download" name="view-tests.js" location="/test/view-tests.js"/> <resource type="download" name="edit-test-row.js" location="/test/edit-test-row.js"/> <resource type="download" name="test-row.js" location="/test/test-row.js"/> <resource type="download" name="view-tests.vm" location="/test/view-tests.vm"/> <resource type="download" name="view-test-days.vm" location="/test/view-test-days.vm"/> <context>my-resources</context> <transformation extension="soy"> <transformer key="soyTransformer"/> </transformation> <resource type="download" name="templates.soy.js" location="/templates/templates.soy"/> <transformation extension="js"> <transformer key="jsI18n"/> </transformation> </web-resource>
{namespace JIRA.Templates.Test} {template .helloWorld} <div>Hello !</div> {/template}
jQuery(function () { AJS.$('#edit-tests').click(function() { var template = JIRA.Templates.Test.helloWorld(); }); })
Community moderators have prevented the ability to post new answers.
Hi Natalia,
I did not use SOY for a while and I can not tell you what is wrong with your sample but here is snippet from my old project:
{namespace Confluence.Templates.SomeName} {template .someFunction} {/template}
and in JS I have:
"use strict"; define('_myEntryName', [ 'jquery', 'confluence/templates'], function($, Templates) { ... Templates.SomeName.someFunction(); ... });
Maybe reason is that JS compiled from the SOY templates does not declare global JS variable but AMD entry so it should be referred as in the code block above. Anyway I remember that I had to look into Confluence/JIRA sources to make it work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.