You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working on #1177, we made a wagtail-editable model EventNotice that contains a set of messages that would appear on every event detail page. We also wanted to have the message include details specific to the event being rendered. To that end, we started registering a new rich text editor feature within the hooks:
@hooks.register("register_rich_text_features")defregister_ecomment_feature(features):
"""Register the ecomment link type"""feature_name="ecomment_link"type_="ecomment_link"control= {
"type": type_,
"label": "E",
"description": "Ecomment Link",
"element": "a",
}
features.register_editor_plugin(
"draftail", feature_name, draftail_features.BlockFeature(control)
)
from_format_str= (
"a[href={{event.ecomment_url}}][target=_blank]"+"[aria-label='Go to public comment - link opens in a new tab']"
)
features.register_converter_rule(
"contentstate",
feature_name,
{
"from_database_format": {from_format_str: BlockElementHandler(type_)},
"to_database_format": {
"block_map": {
type_: {
"element": "a",
"props": {
"href": "{{event.ecomment_url}}",
"target": "_blank",
"aria-label": "Go to public comment - link opens in a new tab",
},
}
}
},
},
)
Unfortunately, simply saving the django template variable to the model does not allow it to render correctly when taken back out. Let's do some further research on this. Maybe there's a way we can have from_database_format render a template instead of a straight up string.
The text was updated successfully, but these errors were encountered:
When working on #1177, we made a wagtail-editable model
EventNotice
that contains a set of messages that would appear on every event detail page. We also wanted to have the message include details specific to the event being rendered. To that end, we started registering a new rich text editor feature within the hooks:Unfortunately, simply saving the django template variable to the model does not allow it to render correctly when taken back out. Let's do some further research on this. Maybe there's a way we can have
from_database_format
render a template instead of a straight up string.The text was updated successfully, but these errors were encountered: