use when instead of if because there is no else - cl-yag - Common Lisp Yet Another website Generator
HTML git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/cl-yag/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit b0cd4f627992889230b31f3b414d0cbd16099610
DIR parent fb05dcdf99bb18fa6d9fe26569d3cf018c837443
HTML Author: Solene Rapenne <solene@dataswamp.org>
Date: Fri, 6 May 2016 16:36:06 +0200
use when instead of if because there is no else
Diffstat:
M generator.lisp | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
---
DIR diff --git a/generator.lisp b/generator.lisp
@@ -67,12 +67,12 @@
(defun articles-by-tag()
(let ((tag-list))
(loop for article in *articles* do
- (if (getf article :tag nil) ;; we don't want an error if no tag
- (loop for tag in (split-str (getf article :tag)) do ;; for each word in tag keyword
- (setf (getf tag-list (intern tag "KEYWORD")) ;; we create the keyword is inexistent and add ID to :value
- (list
- :name tag
- :value (push (getf article :id) (getf (getf tag-list (intern tag "KEYWORD")) :value)))))))
+ (when (getf article :tag nil) ;; we don't want an error if no tag
+ (loop for tag in (split-str (getf article :tag)) do ;; for each word in tag keyword
+ (setf (getf tag-list (intern tag "KEYWORD")) ;; we create the keyword is inexistent and add ID to :value
+ (list
+ :name tag
+ :value (push (getf article :id) (getf (getf tag-list (intern tag "KEYWORD")) :value)))))))
(loop for i from 1 to (length tag-list) by 2 collect ;; removing the keywords
(nth i tag-list))))
@@ -102,7 +102,8 @@
(template "%%Id%%" (getf article :id))
(template "%%Tags%%" (get-tag-list-article article))
(template "%%Text%%" (if (and tiny (member :tiny article))
- (getf article :tiny) (load-file (format nil "data/~d.txt" (getf article :id)))))))
+ (getf article :tiny)
+ (load-file (format nil "data/~d.txt" (getf article :id)))))))
;; return a html string
;; produce the code of a whole page with title+layout with the parameter as the content