dodotable.environment.flask
— Flask environment¶
Yet, dodotable only supports Jinja2 for template, it can be possible to use another template engine but if you have a mind to use Jinja2, maybe you have interest with Flask either.
Originally dodotable are intended to use with Flask, so its environment class is provided.
Customize HTML¶
Maybe you wish to change a design of your table or add some help message, give your class name on HTML elements. So all you have to do is inehrit one of environment class, and use it in your table.
# yourapplication/dodotable.py
from dodotable.schema import Column as SchemaColumn, Table as SchemaTable
from dodotable.environment.flask import FlaskEnvironment
from jinja2 import PackageLoader
class CustomEnvironment(FlaskEnvironment):
@property
def template_loader(self):
return PackageLoader('yourapplication', 'templates')
class Column(SchemaColumn):
environment = CustomEnvironment()
class Table(SchemaTable):
environment = CustomEnvironment()
#yourapplication/app.py
from flask import Flask, render_template
from .dodotable import Table, Column
app = Flask(__name__)
@app.route('/', methods=['GET'])
def index():
table = Table(columns=[
Column(...)
], ...)
return render_template('index.html', table=table.select(0, 10))