インラインJavaScriptを生成しようとしていますが、(:script)
内にparenscriptコードを入れ、cl-whoを使用して(str)
タグを入れなければなりません。 ps
,ps*
,ps-inline
およびps-inline*
は、生成されたjsと大きな違いはないようです。cl-who、parenscript、hunchentootを使用したインラインJavaScriptの生成
コードの重複を避けるためにマクロを書く一般的な方法はありますか、それとも良い方法がありますか?
(in-package #:ps-test)
(defmacro standard-page ((&key title) &body body)
`(with-html-output-to-string (*standard-output* nil :prologue t :indent t)
(:html
:lang "en"
(:head
(:meta :http-equiv "Content-Type"
:content "text/html;charset=utf-8")
(:title ,title)
(:link :type "text/css"
:rel "stylesheet"
:href "/style.css"))
(:body
,@body))))
(defun main()
(with-html-output (*standard-output* nil :indent t :prologue nil)
(standard-page (:title "Parenscript test")
(:div (str "Hello worldzors"))
(:script :type "text/javascript"
(str (ps (alert "Hello world as well")))))))
(define-easy-handler (docroot :uri "/")()
(main))
(defun start-ps-test()
(setf (html-mode) :html5)
(setf *js-string-delimiter* #\")
(start (make-instance 'hunchentoot:easy-acceptor :port 8080)))
(defun stop-ps-test()
(stop *server*))
(defvar *server* (start-ps-test))