Introduction to Nunjucks
Nunjucks is a sophisticated templating engine for JavaScript. It lets you insert dynamic content in any text through the use of templates. A template contains variables and/or expressions, which get replaced with values when a template is rendered; and tags, which control the logic of the template. See here for an overview of the templating features available in Nunjucks.
Nunjucks in JMWE for JIRA Cloud
Nunjucks in JMWE for JIRA Cloud is used to insert information while
- Setting a field value by a post-function
- Commenting an issue by a post-function
- Conditionally executing a post-function
You can insert issue and transition information into the value using the templating features available in Nunjucks. Some basic templating features are described in this document, and more are documented on the Nunjucks website.
On this page:
Templating features in Nunjucks
- Nunjucks template editor and tester
- Variables used in Nunjucks templates — A variable looks up a value from the template context. This documents details on the variables available in JMWE and how to create custom variables.
- Built in Nunjucks Filters — Filters are essentially functions that can be applied to variables. This document details some of the Nunjucks built-in filters.
- Custom Nunjucks filters — Filters are essentially functions that can be applied to variables. Filters are called with a pipe operator (|) and can take arguments. This document details custom Nunjucks filters created for JMWE.
- Tags and Expressions — Tags are special blocks that perform operations on sections of the template and Expressions are literal expressions similar to those in javascript.
- Accessing the details of an issue or a transition in Nunjucks — This document explains how to access the details of issue and transition objects, such as those available through the issue and transition variables. To see an example of the structure of an issue go to <base_URL_of_Jira>/rest/api/latest/issue/{issueKey}. The fields displayed through this REST API actually depend on the fields set on the issue.
- Conditional execution — Post functions are provided with an option to control their execution. You need to input a Nunjucks template in the Condition field, and based on the result of that expression, the post-function will either be executed or skipped.
- Shared Nunjucks Templates
You might also want to look at Accessing the details of an issue or a transition in Nunjucks to know how to access the details of an issue or a transition.
See here for more templating features available in Nunjucks. You might also want to refer here for use cases with Nunjucks annotations.