Page tree
Skip to end of metadata
Go to start of metadata

Starting with version 1.0.9-AC, JMWE for JIRA Cloud provides a Nunjucks template editor and tester in the post-function configuration screens. This document details their availability and features.

Nunjucks editor and tester availability

  • The Nunjucks template editor and tester are available on the:

    • Nunjucks tester on the JMWE Administration section - This page allows you to test Nunjucks expressions against JIRA issues without needing to edit a workflow transition.
    • Post-function configuration screen of post-functions that:
      • Set a field value
      • Comment an issue
    • Post-function configuration of the Create issue post-function when you 
      • Select a destination project using the Calculated option
      • Specify the parent issue using the Another issue option
      • Set a field of the new issue using the Set field value to option
      • Add a comment to the current issue
    • Post-function configuration screen of Transition [current/linked/parent] issue post-functions when you:
      • Set value of fields on the Transition screen
      • Add a comment during the transition
    • Post-function configuration screen of any post-function when you select the Conditional execution option.

On this page:

Nunjucks editor

Nunjucks editor features

The Nunjucks editor in JMWE Cloud is available for all input fields that support Nunjucks annotations. This editor has the ability to:

  • Check for syntax errors in the code

  • Colorize keywords, comments, variables and so on

The editor also provides advanced features, such as find and replace, that are available through keyboard shortcuts.

Nunjucks editor keyboard shortcuts

You can use the following shortcut keys as an alternative to the mouse when working in this editor, while the cursor is active in the editor: 


Opens the search box. Use /re/ syntax for regexp search

findNextPost a search, finds the next occurrence of the searchCtrl-GCmd-G
findPrevPost a search, finds the previous occurrence of the searchShift-Ctrl-GShift-Cmd-G

Opens the Replace window.

replaceAllOpens the Replace all windowShift-Ctrl-RShift-Cmd-Alt-F
selectAllSelect the whole content of the editorCtrl-ACmd-A
singleSelectionWhen multiple selections are present, this deselects all but the primary selectionEscEsc
killLineDeletes the part of the line after the cursor. If that consists only of whitespace, the newline at the end of the line is also deleted.
deleteLineDeletes the whole line under the cursor, including newline at the end.Ctrl-DCmd-D
delWrappedLineLeftDelete the part of the line from the left side of the visual line the cursor is on to the cursor.
delWrappedLineRightDelete the part of the line from the cursor to the right side of the visual line the cursor is on.
undoUndo the last changeCtrl-ZCmd-Z
redoRedo the last undone changeCtrl-YShift-Cmd-Z or Cmd-Y
undoSelectionUndo the last change to the selection, or if there are no selection only changes at the top of the history, undo the last change.Ctrl-UCmd-U
redoSelectionRedo the last change to the selection, or the last text change if no selection changes remain.Alt-UShift-Cmd-U
goDocStartMove the cursor to the start of the document.Ctrl-HomeCmd-Up or Cmd-Home
goDocEndMove the cursor to the end of the document.Ctrl-EndCmd-End or Cmd-Down
goLineStartMove the cursor to the start of the line.Alt-LeftCtrl-A
goLineStartSmartMove to the start of the text on the line, or if we are already there, to the actual start of the line (including whitespace).HomeHome
goLineEndMove the cursor to the end of the line.Alt-RightCtrl-E
goLineRightMove the cursor to the right side of the visual line it is on.
goLineLeftMove the cursor to the left side of the visual line it is on. If this line is wrapped, that may not be the start of the line.
goLineUpMove the cursor up one line.UpCtrl-P
goLineDownMove down one line.DownCtrl-N
goPageUpMove the cursor up one screen and scroll up by the same distance.PageUpShift-Ctrl-V
goPageDownMove the cursor down one screen and scroll down by the same distance.PageDownCtrl-V
goCharLeftMove the cursor one character left, going to the previous line when hitting the start of the line.LeftCtrl-B
goCharRightMove the cursor one character right, going to the next line when hitting the end of the line.RightCtrl-F
goWordLeftMove the cursor to the start of the previous word.
goWordRightMove the cursor to the end of the next word.
goGroupLeftMove to the left of the group before the cursor. Ctrl-LeftAlt-Left
goGroupRightMove to the right of the group after the cursor.Ctrl-RightAlt-Right
delCharBeforeDelete the character before the cursor.Shift-BackspaceCtrl-H
delCharAfterDelete the character after the cursor.DeleteCtrl-D
delWordBeforeDelete up to the start of the word before the cursor.
delWordAfterDelete up to the end of the word after the cursor.
delGroupBeforeDelete to the left of the group before the cursor.Ctrl-BackspaceAlt-Backspace
delGroupAfterDelete to the start of the group after the cursor.Ctrl-DeleteCtrl-Alt-Backspace or Alt-Delete
indentAutoAuto-indent the current line or selection.Shift-TabShift-Tab
indentMoreIndent the current line or selection by one indent unit.Ctrl-]Cmd-]
indentLessDedent the current line or selection by one indent unit.Ctrl-[Cmd-[
defaultTabIf something is selected, indent it by one indent unit. If nothing is selected, insert a tab character.TabTab
transposeCharsSwap the characters before and after the cursor.
newlineAndIndentInsert a newline and auto-indent the new line.EnterEnter
toggleOverwriteFlip the overwrite flag.InsertInsert

A group is a stretch of word characters, a stretch of punctuation characters, a newline, or a stretch of more than one whitespace character.

Nunjucks tester

The Nunjucks template tester tool lets you test your template against any issue. The main advantage of this tool is that you can quickly test and debug your template and make changes without having to actually trigger the transition and/or look at the JMWE logs to see the result.

Using the Nunjucks tester

After writing your Nunjucks template in the editor, click on Test Nunjucks template. A window opens, asking you to input an issue to run the Nunjucks template against, and select a linked issue where applicable. The issue and linkedIssue variables used in your template will point to these issues. 

In post-functions that process linked issues, after you input an issue, all issues linked to it through the link type selected in Issue link are displayed under Linked issue key. The linkedIssue variable used in your template will point to the linked issue you select.

In the post-functions that process the parent issue, after you input an issue, its parent is displayed under Parent issue keyThe parentIssue variable used in your template will point to the parent issue you select.

The transition variable will not reflect transition information during testing.

Testing your Nunjucks template

After selecting issue(s) against which the template should be tested, click on Test. The following information will be displayed. This information can be used for debugging.

  1. Message: Success/error message based on the test result.

  2. Result value: Value of the result.


Test a template that fetches the username of the user the issue is assigned to:

  • Add the Set field value post-function to a transition.
  • In the Nunjucks editor, write the following lines of code:

    {{ }}
  • Click on Test Nunjucks template
  • Type the Issue key of an issue assigned to a valid user.
  • Click on Test.
  • The following result is displayed:

Debugging your template

If you encounter an error during testing or your template doesn't seem to work as expected, you will need to debug your template. The information displayed in the template tester result panel aids in debugging the script.

Consider the following template to return the name of the last Fix Version/s of an issue. Write it in the Nunjucks editor.

{{ issue.fields.fixVersions | Last }}
  • Test the script, as explained above against an issue that has Fix Version/s. The following result is displayed.

  • Identify the problem, from the Message that displayed an error that the specified filter was not found.
  • Correct the problem, by referring the specified filter details from filters documentation and adding the correct one.

    {{ issue.fields.fixVersions | last }}
  • Retest the template, by clicking on Test again and verify the result in the template test panel.

Since you wish to return the name of the last Fix Version/s of an issue, as mentioned in the result panel you might want to use the dump filter.

  • Edit the template, and add the dump filter to see the object's fields.

    {{ issue.fields.fixVersions | dump(2) }}
  • Retest the template, by clicking on Test again and verify the result in the template test panel.

Since you need the name of the version, use the field filter to fetch it.

  • Edit the template, remove the dump filter and add the field filter.

    {{ issue.fields.fixVersions | last | field("name")}}
  • Retest the template, by clicking on Test again and verify the result in the template test panel.

  • No labels