;;;;;; 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 %}
""")(defunrender(s&restkeys)(apply#'djula:render-template*(djula:compile-strings)nil;; key arguments:keys))#++(render*template-hello*:foot);; =>" foo is true "
Good question, I'll tell when I can… did you try other templating engines? I hear good things about this one, and it seems more appropriate: github.com/moderninterpreters/markup
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (3)
Know of a way to use include with this method? I've tried several methods, and all have failed.
so yeah, currently this isn't possible,
includeexpects a path.Good question, I'll tell when I can… did you try other templating engines? I hear good things about this one, and it seems more appropriate: github.com/moderninterpreters/markup