;;;
;;; How to use Djula templates in-file, without separate file templates.
;;;
;;; This can make it easier to ship your app as a single binary.
;;; Otherwise, see
;;; https://lisp-journey.gitlab.io/blog/lisp-for-the-web-build-standalone-binaries-foreign-libraries-templates-static-assets/#embed-html-djula-templates-in-your-binary
;;;
;;; We use two Djula functions:
;;; - compile-string
;;; - render-template*
;;;
;;;
#++
(ql:quickload '("djula" "pythonic-string-reader"))
(pythonic-string-reader:enable-pythonic-string-syntax)
(defparameter *template-hello* """
{% if foo %}
foo is true
{% else %}
foo is false
{% endif %}
""")
(defun render (s &rest keys)
(apply
#'djula:render-template*
(djula:compile-string s)
nil
;; key arguments:
keys
))
#++
(render *template-hello* :foo t)
;; =>
" foo is true "
Hands-on debugging session: instrument, monitor, and fix
Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)