Cache Markdown'ed HTML in database

This is done via coercion rules. To cache the field 'content' in the
database, include this in your Eve schema:

    {'content': {'type': 'string', 'coerce': 'markdown'},
     '_content_html': {'type': 'string'}}

The `_content_html` field will be filled automatically when saving the
document via Eve.

To display the cached HTML, and fall back to display-time rendering if it
is not there, use `{{ document | markdowned('content') }}` in your template.

Still needs unit testing, a CLI command for regenerating the caches, and
a CLI command for migrating the node type definitions in existing projects.
This commit is contained in:
2018-03-26 18:49:01 +02:00
parent 08ce84fe31
commit dfaac59e20
22 changed files with 179 additions and 52 deletions

View File

@@ -36,7 +36,7 @@ zencoder==0.6.5
amqp==2.1.4
billiard==3.5.0.2
Flask-PyMongo==0.4.1
Cerberus==0.9.2
-e git+git@github.com:armadillica/cerberus.git@sybren-0.9#egg=Cerberus
Events==0.2.2
future==0.15.2
html5lib==0.9999999