Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Having trouble referencing soy template

N March 23, 2017

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">
    <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"/>    
      <transformation extension="soy">
          <transformer key="soyTransformer"/>
        <resource type="download" name="" location="/templates/"/>
      <transformation extension="js">
            <transformer key="jsI18n"/>
{namespace JIRA.Templates.Test}
{template .helloWorld}
<div>Hello !</div>
jQuery(function () {
     AJS.$('#edit-tests').click(function() {   
        var template = JIRA.Templates.Test.helloWorld();

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 24, 2017

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}

and in JS I have:

"use strict";
define('_myEntryName', [ 'jquery', 'confluence/templates'], function($, Templates) {

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.

AUG Leaders

Atlassian Community Events