Snippets embedder for Wagtail RichTextField.
Project description
wagtailembedder
==================
![Wagtailembedder scnreenshot](http://i.imgur.com/qDPKz7r.png)
Snippets embedder for Wagtail RichTextField.
# Quickstart
Install the package with ``` $ pip install wagtailembedder```
Add `wagtailembedder` to your `settings.py` in the `INSTALLED_APPS` section:
```python
INSTALLED_APPS = [
...
'modelcluster',
'wagtailembedder',
'core',
...
]
```
For each models registered as a wagtail.wagtailsnippets create an html file to render the template inside a RichText field.
* Templates names will match snippets models names replacing capital letters with underscores, Wagtail style.
For the ```SocialMediaLink``` snippet in the ```core``` app, it will look for the following template ```core/templates/snippets/socialmedialink.html```.
* The variable containing the snippet instance in the template is ```snippet```.
If no template is defined then an exception will be raised in the frontend when rendering a RichTextField with the embedded snippet in it. Make sure you write some templates for your snippets before start to embedding them.
# Options
If the snippet meta has a description field, it will show up next to the snippet name in the admin interface.
```python
from django.db import models
import django.db.models.options as options
options.DEFAULT_NAMES = options.DEFAULT_NAMES + ('description',)
@register_snippet
class MySnippet(models.Model):
# fields definition
class Meta:
description = "My Snippet Description"
```
==================
![Wagtailembedder scnreenshot](http://i.imgur.com/qDPKz7r.png)
Snippets embedder for Wagtail RichTextField.
# Quickstart
Install the package with ``` $ pip install wagtailembedder```
Add `wagtailembedder` to your `settings.py` in the `INSTALLED_APPS` section:
```python
INSTALLED_APPS = [
...
'modelcluster',
'wagtailembedder',
'core',
...
]
```
For each models registered as a wagtail.wagtailsnippets create an html file to render the template inside a RichText field.
* Templates names will match snippets models names replacing capital letters with underscores, Wagtail style.
For the ```SocialMediaLink``` snippet in the ```core``` app, it will look for the following template ```core/templates/snippets/socialmedialink.html```.
* The variable containing the snippet instance in the template is ```snippet```.
If no template is defined then an exception will be raised in the frontend when rendering a RichTextField with the embedded snippet in it. Make sure you write some templates for your snippets before start to embedding them.
# Options
If the snippet meta has a description field, it will show up next to the snippet name in the admin interface.
```python
from django.db import models
import django.db.models.options as options
options.DEFAULT_NAMES = options.DEFAULT_NAMES + ('description',)
@register_snippet
class MySnippet(models.Model):
# fields definition
class Meta:
description = "My Snippet Description"
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wagtailembedder-1.1.tar.gz
(7.6 kB
view hashes)
Built Distribution
Close
Hashes for wagtailembedder-1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fe7b77511898c88db60dc32e05fc524feb6b3f6ab6218f181e48e2c4ad1bb14 |
|
MD5 | 7cca40d9fa3f4237f506f96eec79b71b |
|
BLAKE2b-256 | 4a3b1eb13a2195931d615222c7d9ee015f2ab2fc4d0bb70779b25cdcf009a858 |