Commit e21dcf77 authored by Dave Cooper's avatar Dave Cooper

Merge common-lisp.net:clo/cl-site

parents 5cbd0ab6 7eb5cde0
......@@ -12,9 +12,9 @@
when (string= line "---") return lines
collect line into lines)))
(loop for line = (read-line f nil)
collect line into lines
unless line
return (values header-lines lines)))))
return (values header-lines lines)
collect line into lines))))
;; Copies/renders static assets (imgs, etc)
(defun process-static ()
......@@ -33,6 +33,14 @@
;; process-pages : Copies/renders pages - called last
(defun render-template (template &optional context output-stream)
(let ((mustache:*load-path* (cons *PAGES-DIR* mustache:*load-path*))
(mustache:*default-pathname-type* "html"))
(mustache:render template context output-stream)))
(defun render-template* (template &optional context)
(with-output-to-string (output-stream)
(render-template template context output-stream)))
(defun render-page (page template-path)
(let ((page-path (make-path *PAGES-DIR* page t))
......@@ -44,14 +52,15 @@
(content-text (format nil "~{~A~%~}" (remove nil content)))
(parsed-header (yaml:parse header-text))
(page-context
(when parsed-header
(loop for k being each hash-key of parsed-header
using (hash-value v)
collect (cons k v)))))
(when parsed-header
(loop for k being each hash-key of parsed-header
using (hash-value v)
collect (cons k v)))))
(with-open-file (output-stream output-path
:direction :output
:if-exists :supersede)
(mustache:render template-path (append (acons :page-content content-text page-context) *GLOBAL-CONTEXT*)
:direction :output
:if-exists :supersede)
(render-template template-path
(append (acons :page-content (render-template* content-text) page-context) *GLOBAL-CONTEXT*)
output-stream))))))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment