mmontone / cl-forms

Web forms handling library for Common lisp
http://mmontone.github.io/cl-forms
MIT License
43 stars 5 forks source link

feature request: spinneret #5

Closed jgarte closed 2 years ago

jgarte commented 2 years ago

Hi could this library support spinneret?

If so, what would be required?

mmontone commented 2 years ago

Hi. Would require a Spinneret renderer.

The equivalent of this file: https://github.com/mmontone/cl-forms/blob/master/src/renderer/who.lisp, but using Spinneret instead of cl-who.

mmontone commented 2 years ago

I think you may be able to mix both cl-who and spinneret,though. If both libraries write to the same output stream..

mmontone commented 2 years ago

I have an example of using cl-who renderer and spinneret at the same time:

(forms:defform my-form ()
     ((input :string)))

(let ((form (forms:get-form 'my-form)))
     (with-output-to-string (*html*) 
       (spinneret:with-html
         (let ((cl-forms.who:*html* *html*)
           (spinneret:*html* *html*))
           (:h1 "This is my form")
           (forms:with-form-renderer :who
         (forms:render-form form))
           (:ul
        (loop for i from 1 to 10
              do (:li (princ-to-string i))))))))

There may be a cleaner way of connecting things. Feels like a macro should be implemented there .. But this works. cl-who html stream, cl-forms.who:*html* and spinneret:*html* are all bound to the same output stream.