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

@@ -15,7 +15,7 @@
| {% if node.description %}
.node-details-description
| {{ node.description | markdown }}
| {{ node | markdowned('description') }}
| {% endif %}
section.node-children.group