Flask-Htmldoom: htmldoom integration for Flask

github logo Updated on ・1 min read

Yesterday I published htmldoom, An intuitive, high performance HTML rendering framework, with a Pyramid plugin and a reverse converter

Today I'm glad to publish the Flask plugin.

GitHub logo sayanarijit / flask-htmldoom

htmldoom integration for Flask

Flask-Htmldoom

htmldoom integration for Flask

Checkout the live demo with performance debugging

Usage

Install

pip install Flask-Htmldoom

Plug into Flask

app.py

import os
from flask import Flask
from flask_htmldoom import render_template
app = Flask(__name__)


@app.route("/")
def hello_htmldoom_view():
    """htmldoom rendered view"""
    return render_template("templates.hello", data="Hello htmldoom")


if __name__ == "__main__":
    app.run("0.0.0.0", int(os.environ.get("PORT", "8080")), debug=True)

templates/hello.py

from htmldoom import elements as e
from htmldoom import renders
from .layout import render_document


@renders(
    e.body()(
        e.h3()("{contents}"),
        e.a(href="/")("Home"),
    )
)
def render_body(data):
    return {"contents": data["data"]}


def render(data):
    return render_document(data, body_renderer=

with a live demo and live performance monitor.

twitter logo DISCUSS
Classic DEV Post from May 24

ECMAScript Classes - Keeping Things Private

Arijit Basu profile image

dev.to now has dark theme. 🌝

Go to the "misc" section of your settings and select night theme

P.S. It's also the best place to talk code amongst thoughtful developers, and it's totally open source.