Вопрос

(require :cl-who)
(defmacro rawpage ((&rest head) &body body)
  `(cl-who:with-html-output-to-string (*standard-output* nil :prologue t)
    (:html
    (:head
      (:meta :charset "utf-8")
      ,@head)
    (:body
      ,@body))))

(defmacro str+ (&rest strs)
  `(concatenate 'string ,@strs))

(rawpage () (:div (str+ "hello," "name")))

This piece of codes does not output what I want. I expected it output:

<html><head><meta charset='utf-8' /></head><body><div>hello,name</div></body></html>

But, it output:

<html><head><meta charset='utf-8' /></head><body><div></div></body></html>

Anyone could tell me why? I'm using SBCL.

Это было полезно?

Решение

Your problem is that in CL-WHO non-constant strings should be placed inside str like this:

(defmacro rawpage ()
  (:div (str (str+ "hello," "name"))))
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top