home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 719803880

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions issue performed_via_github_app
https://github.com/simonw/datasette/issues/1072#issuecomment-719803880 https://api.github.com/repos/simonw/datasette/issues/1072 719803880 MDEyOklzc3VlQ29tbWVudDcxOTgwMzg4MA== 9599 2020-10-30T21:17:11Z 2020-10-30T21:17:11Z OWNER

Example from the Jinja docs: https://jinja.palletsprojects.com/en/2.11.x/api/#jinja2.BaseLoader

```python from jinja2 import BaseLoader, TemplateNotFound from os.path import join, exists, getmtime

class MyLoader(BaseLoader):

def __init__(self, path):
    self.path = path

def get_source(self, environment, template):
    path = join(self.path, template)
    if not exists(path):
        raise TemplateNotFound(template)
    mtime = getmtime(path)
    with file(path) as f:
        source = f.read().decode('utf-8')
    return source, path, lambda: mtime == getmtime(path)

Also available: `jinja2.FunctionLoader(load_func)` which lets me pass it a function like this one:

def load_template(name): ... if name == 'index.html': ... return '...' ... loader = FunctionLoader(load_template) ```

Just one catch: I need to be able to load templates asynchronously, because they live in the database. Let's hope Jinja has a mechanism for that!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
733499930  
Powered by Datasette · Queries took 1.805ms · About: github-to-sqlite