Closed geekman closed 10 years ago
Unfortunately not. Acrylamid can not track dependencies used in attributes and has no ability to use filters (which is probably the feature you want there) in tags. For attributes, you have to use hard-coded values.
I managed to do it by processing entry.content
in the template itself. Problem now is I need to add Jinja2 filters so that the templates can access it when processing the <meta>
tags.
What would you recommend is the best way to insert a global filter (without modifying the acrylamid source)? I've looked at the jinja2 filter but that filters the entry body and doesn't run when processing the top-level template.
You can create a custom, no-op view and register your filter there: https://github.com/posativ/acrylamid/blob/master/acrylamid/views/tag.py#L106
Yeap actually that's what I did, but it's still not very ideal as the no-op view still needs to have some boilerplate code to satisfy being a View.
VIEWS
in conf.py
with some dummy route. Otherwise it never gets executedgenerate
method must be present and must return valid data.
generate
is missing, it fails with object has no attribute 'generate'
generate
is pass
or return
, it fails with NoneType is not iterable
. helpers.mkfile
will complainHopefully there will be another type of plugin in future that is able to suit this need that might not be so hacky, but this works for now.
Thanks :)
Currently each entry has a
description
, inherited from theMetadataMixin
, but if not defined in the front matter it will be computed usingself.source[:50]
. This produces undesired results if the an image markup is within the first 50 characters.Also, how would one extract the first image from the (processed) entry body and populate it in a meta tag like
twitter:image:src
?Without resorting to regex hacks, would it be possible to obtain and manipulate the processed entry body during template rendering?