[NEW] jack is a HTML renderer library for Emacs Lisp | you might find it useful reddit / emacs ---------------------------------------------------------------------- tonyaldon · 2022-11-11 09:04 ---------------------------------------------------------------------- _viz_ · 2022-11-11 11:17 Having read the readme, I wonder if renderer library is the right word: I was hoping to see a comparison with shr's table rendering but AFAIU, this is a translator to HTML just like rx right? ---------------------------------------------------------------------- HM0880 · 2022-11-11 13:11 Agreed. `jack` looks more like a (very nice!) HTML snippet expansion library. ---------------------------------------------------------------------- your_sweetpea · 2022-11-11 15:25 I agree that renderer isn't exactly the right word, but this is a useful library regardless -- I on-and-off end up playing with org and something like this for richer static site generation than just ox- html and css. ---------------------------------------------------------------------- noman_032018 · 2022-11-11 16:09 That looks more like an Emacs Lisp equivalent to [CL's Spinneret](https://github.com/ruricolist/spinneret) than a renderer. Quite nice, but also not quite the same use-case. ---------------------------------------------------------------------- donio · 2022-11-11 17:06 Yeah, I'd go with HTML generator. ---------------------------------------------------------------------- harsh_mistress · 2022-11-11 17:29 consider changing the name for the sake of discoverability/troubleshooting/docs searching because [Jack](https://jackaudio.org/) is a pretty well known linux audio server API/daemon ---------------------------------------------------------------------- wasamasa · 2022-11-11 19:51 I got a bit excited about an alternative to shr.el, but then read your comment. Thanks for pointing this out. ---------------------------------------------------------------------- noman_032018 · 2022-11-11 19:59 Even just adding `el-` in front would probably do enough to disambiguate usefully. ---------------------------------------------------------------------- tonyaldon · 2022-11-12 05:44 Thanks for pointing that out. I've just updated the repository and the docs. I changed from 'renderer' to 'generator' and 'render' to 'generate'. ---------------------------------------------------------------------- tonyaldon · 2022-11-12 06:32 I've just changed from 'renderer' to 'generator' in the repository. You've got it right :) I wrote this library to write static sites with Elisp. I've already build https://dieta.tonyaldon.com with `jack`. The data are stored in a list of plist like this: (setq dieta-db '((:date "2022-01-07" :desayuno "fruta + cereales + yogur" :almuerzo "tostadas de humus" :merienda "tostadas de humus" :comida "pescado + judías" :cena "bocadillo (hamburgesa + queso + tomate)") (:date "2022-01-08" :desayuno "barritas de cereales" :almuerzo "no" :merienda "fruta" :comida "filete de ternera + patatas fritas" :cena "restaurante (Indio)") ...)) and the pages are generated with `jack`. For instance this is part of the home page: (defun dieta-home (db components scripts) "Produce HTML string of the home page." (interactive) (jack-html "" `(:html (:head ,(plist-get components :headers) (:script (@ :src (plist-get scripts :hyperscript-url)))) (:body (:script (@ :type "text/hyperscript") "...hyperscript and js functions here.....") (:section/main (@ :_ (concat "on load showToday()")) (:div.navbar (:div/app-title "DIETA") (:div/love "Tony ♥ Nieves") (:div (:a.button (@ :href "/archivos/") "Archivos"))) (:div/more.hidden (@ :data-more "more" :_ "on click moreDaysToggle(me)") "MÁS...") ;; add all days that come after yesterday ,(let ((yesterday-time (time-add (current-time) -86400))) ;; (* 24 3600) (delq nil (mapcar (lambda (d) (let* ((d-iso-date (concat (plist-get d :date) "T00:00:00")) (d-time (date-to-time d-iso-date))) (when (time-less-p yesterday-time d-time) (dieta-day d "hidden")))) db))) (:div.tabs (@ :_ "def updateTabs(elt) if I do not match .active remove .active from <.tabs div/> add .active to elt end end") (:div.active (@ :_ "on click updateTabs(me) showToday()") "hoy") (:div (@ :_ "on click updateTabs(me) showWeek()") "semana") (:div (@ :_ "on click toggle .hidden on <.breakfast/>") "desayuno")))) (:script ,(plist-get scripts :service-worker))))) For the dynamic part I use https://hyperscript.org/. You can take a look at the code: https://gitlab.com/tonyaldon/dieta. Have a nice week-end. ---------------------------------------------------------------------- tonyaldon · 2022-11-12 06:35 thanks for the advice. ---------------------------------------------------------------------- tonyaldon · 2022-11-12 06:36 I didn't know about Spinneret. Thanks for sharing.