Jinja2 templates
Jinja2 is a Python library that you can use to construct templates for various output formats from a core template text file. It can be used to create HTML templates for IBM® QRadar® applications.
Jinja2 has a rich API, and large array of syntactic directives (statements, expressions, variables, tags) that allow the dynamic injection of content into the templated file.
Use the Flask render_template() method in the app's views.py file to inject data from your Python method, served by the route, into a Jinja2 templated HTML file. For example:
__author__ = 'IBM'
from flask import render_template
from app import app
@app.route('/')
def hello_world():
return render_template("hello.html", title = "QRadar")
The hello.html template must be stored in the /app/templates folder. The hello.html file is described in the following section:
<!doctype html>
<title>Hello from Flask</title>
<h1>Hello {{ title }}!</h1>
<!doctype html>
<title>Hello from Flask</title>
<h1>Hello QRadar!</h1>
For more information about Jinja2 templates, see the Jinja2 documentation.
Edit Jinja2 templates in Eclipse
You can use the Django template editor plug-in in Eclipse to develop Jinja2 templates.
PyDev Eclipse does not come with a Jinja2 template editor by default. The Django template editor plug-in offers useful features that you can employ to develop Jinja2 templates for your app.
Install the Django repository (http://pydev.org/updates) by clicking on the main Eclipse Help panel.
This plug-in offers useful syntax-highlighting and auto-completion features for Jinja2 template development.