| Paste number 54023: | Weblocks static HTML widget |
| Pasted by: | Leslie |
| When: | 2 years, 6 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+15ON |
| Channel: | None |
| Paste contents: |
(in-package :weblocks)
(export '(static-html make-static-html-from-file
with-widget-header render-widget-body))
(defwidget static-html (widget)
((html :type string :accessor html :initarg :html :initform ""))
(:documentation "Represents a piece of static HTML body mark-up."))
(defmethod with-widget-header ((widget static-html) body-fn &rest args &key
prewidget-body-fn postwidget-body-fn &allow-other-keys)
(apply body-fn widget args))
(defmethod render-widget-body ((widget static-html) &rest args)
(format *weblocks-output-stream* "~A~_" (html widget)))
(defun make-static-html-from-file (file)
"Create a static-html widget representing the mark-up in “file”."
(with-open-file (input file :direction :input)
(let ((data (make-string (file-length input))))
(read-sequence data input)
(make-instance 'static-html :html data))))This paste has no annotations.