implemented loading templates from specified template folder

updated old usage of force-log
This commit is contained in:
a. fox 2024-01-23 15:28:23 -05:00
parent 895e54a44b
commit bbdba72c8a
3 changed files with 11 additions and 3 deletions

View File

@ -84,6 +84,13 @@
(translate-logical-pathname "web:static;"))
(log:debug "Using ~A for templates."
(translate-logical-pathname "web:template;"))
(log:info "loading templates...")
(let ((*package* #.(find-package :lspx)))
(uiop:collect-sub*directories
"web:template;" (constantly t) (constantly t)
#'(lambda (dir)
(mapcar #'load (uiop:directory-files dir "*.lspt")))))
;; creates our server handler, fetching the port if provided
(setf *server*
@ -108,6 +115,7 @@
(bt:thread-name th)))
(bt:all-threads)))
(error (e)
(force-log "An Unexpected Error Occured:~%~A" e)))
(log:fatal "!!ERROR ~A~%~%BACKTRACE: ~A"
e (trivial-backtrace:print-backtrace e :output nil))))
(clack:stop *server*)))

View File

@ -2,8 +2,7 @@
(defpackage #:lspx
(:use #:cl #:with-user-abort
#:lspx.errors
#:lspx.template)
#:lspx.errors #:lspx.template)
(:local-nicknames (:a :alexandria))
(:import-from :unix-opts
:define-opts

View File

@ -45,6 +45,7 @@
FORMAT is either a format-compatible string or a function that accepts one parameter (the inner-html)
if additional configuration is desired, html attributes of the form attr=\"value\" are converted into :ATTR \"value\" and applied to the function at render time"
(log:info "defining new template for tag ~A" tag)
(setf (gethash tag *custom-tags*)
(typecase format
(string (lambda (in &rest _)