4ch1m / intellij-quick-jinja

A plugin for the IntelliJ platform to quickly render and review Jinja templates.
MIT License
2 stars 1 forks source link
idea intellij intellij-plugin jinja jinja2 plugin

IntelliJ Quick Jinja IntelliJ Quick Jinja IntelliJ Quick Jinja

A plugin for the IntelliJ platform to quickly render and review Jinja templates.

Screenshots

Provide sample variables in a dedicated editor

variables_editor

View the rendered result in either plaintext or HTML mode

result_plaintext

result_html

Quickly choose the source of the template (file, selected text, clipboard)

template_from_selection

template_from_clipboard

Requirements

- A Python interpreter has to be installed on your system. -

The Jinja2 package is also mandatory:

pip3 install Jinja2

Quick Jinja will try to load and use Ansible-specific filters.
So this package is optional:

pip3 install ansible

(NOTE: ansible already includes the Jinja2 package)

Installation

Use the IDE's built-in plugin system:

Or go to the plugin page on the JetBrains-website, download the archive-file and install manually.

Setup

Before actually using Quick Jinja you should check/test your Python environment by using the plugin's settings page:

settings

The plugin does not detect or use any (virtual) environment settings of your current project. However, you can use an individual script/executable that does the necessary/individual preparations.

Example:

Reference this script in the plugin; and you should be ready to go. :thumbsup:

Usage

Everything should be pretty self-explanatory.
Here's a detailed description anyway. :grinning:

usage1

  1. Simply open and use the new tool window to render a Jinja template.
  2. Choose the template source:
    • the complete contents of the currently edited file (automatically changes when switching tabs)
    • just the selected text from the currently opened editor
    • the contents of your clipboard
  3. You can use the pin icon to disable automatic file selection and keep the currently opened document as template-source.
  4. Enter all variables (needed for rendering) in the variables tab.
    Both JSON and YAML definitions are allowed.
  5. The status icon on the right will indicate if parsing of the entered variables was successful.
  6. Alternatively you can choose any file where variables should be loaded from.
  7. Pressing the green run button will try to render the template and switch to the result tab.

usage2

  1. The rendered template (or any errors) will be shown there.
  2. Choose the view mode:
    • Plain text
    • HTML (which should be more suitable when rendering HTML-templates)
  3. The dedicated status icon will also indicate if the rendering process successfully finished.

License

Please read the license file.

Credits

Donate

If you like this plugin, please consider a donation. Thank you!