emacs-love / weblorg

Static Site Generator for Emacs
https://emacs.love/weblorg
GNU General Public License v3.0
279 stars 21 forks source link

feat: Custom filters via weblorg-site #70

Open mgmarlow opened 1 year ago

mgmarlow commented 1 year ago

Add custom templatel filters via weblorg-site. The :filters option takes a list of cons providing the filter name and function. This matches the API outlined in #43.

I'm new to Emacs Lisp so happy to hear any feedback.

Example use:

(defun greeter (name) (concat "Hello, " name "!"))

(weblorg-site
 :filters `(("greet" . greeter)
            ("greet_twice" . (lambda (name) (concat (greeter name) (greeter name))))))

And in the template:

<p>{{ "world" | greet }}</p>
<p>{{ "world" | greet_twice }}</p>