{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Jinja templates" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from jinja2 import Template " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Jinja\n", "\n", "https://jinja.palletsprojects.com/en/2.11.x/\n", "\n", "> Jinja is a modern and designer-friendly templating language for Python (...). It is fast, widely used and secure with the optional sandboxed template execution environment:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Basic usage of Jinja\n", "template = Template('Hello {{ name }}!')\n", "you = 'XPUB1'\n", "output = template.render(name=you)\n", "print(output)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Jinja is very useful for generating HTML pages\n", "# Let's start with a HTML snippet: \n", "template = Template('