posativ / acrylamid

(unmaintained) static blog generator in python with incremental rendering ⛺
http://posativ.org/acrylamid/
Other
277 stars 40 forks source link

Added Replace Filter #230

Closed ckoepp closed 9 years ago

ckoepp commented 9 years ago

I wrote a small filter to replace fixed place-holders with user-defined strings. The filter is configured using the REPLACE_RULES variable in conf.py.

Personally, I use it so simply transform smilies into a Font Awesome icon. It's just way nicer to split design and content by just using :-) in the actual text-files which is than transformed in something more beautiful like a smiley image.

To keep it simple I used a dict as configuration. The key is the place-holder used in the content files and the value describes the string which is than visible in the output:

REPLACE_RULES = {
     ':-)' : '<i class="fa fa-smile-o"></i>',
    '$last_compilation$' : datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
    '~foo~' : 'bar',
}

(...)
FILTERS += ['replace']

I hope there are more people which find this useful...

posativ commented 9 years ago

If you can add a few lines to the documentation, I'll merge the new filter :)

posativ commented 9 years ago

Thanks!