lisp-project-of-the-day icon indicating copy to clipboard operation
lisp-project-of-the-day copied to clipboard

spinneret

Open utterances-bot opened this issue 5 years ago • 11 comments
trafficstars

spinneret

https://40ants.com/lisp-project-of-the-day/2020/09/0189-spinneret.html

utterances-bot avatar Sep 20 '20 08:09 utterances-bot

Thank you for this series of reviews, they are informative and inspiring.

In regards to template libraries, would you consider having a look at xml-generator? It is available here.

lispstudent avatar Sep 20 '20 08:09 lispstudent

I didn't know about xml-generator. Will look at it. Thank you!

svetlyak40wt avatar Sep 20 '20 08:09 svetlyak40wt

Thank you for considering it. It mentions " It mostly should work on other implementations", and I was able to load it from quicklisp's local-projects by commenting out first two ACL specific forms (with #+(version= ...), but got stuck after that, because of ACL named-readtable facility.

lispstudent avatar Sep 20 '20 14:09 lispstudent

Hi, could please show examples of various HTML form elements like option, select, checkbox, textarea etc.

sree-kumar avatar Jun 21 '21 04:06 sree-kumar

@sree-kumar This is very natural. Just use s-expressions the same way as you use HTML tags:

CL-USER> (spinneret:with-html-string
           (:form :action "/some/url" :method "POST"
                  (:select :name "foo"
                    (:option :value 1 "First")
                    (:option :value 2 "Second"))
                  (:textarea :name "Large Text"
                             "Initial text content")))
"<form action=/some/url method=POST>
 <select name=foo>
  <option value=1>First
  <option value=2>Second
 </select>
 <textarea name=\"Large Text\">Initial text content</textarea>
</form>"

svetlyak40wt avatar Jun 21 '21 10:06 svetlyak40wt

Thanks a lot.

On Mon, Jun 21, 2021 at 3:53 PM Alexander Artemenko < @.***> wrote:

@sree-kumar https://github.com/sree-kumar This is very natural. Just use s-expressions the same way as you use HTML tags:

CL-USER> (spinneret:with-html-string (:form :action "/some/url" :method "POST" (:select :name "foo" (:option :value 1 "First") (:option :value 2 "Second")) (:textarea :name "Large Text" "Initial text content")))"

<textarea name="Large Text">Initial text content
"

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/40ants/lisp-project-of-the-day/issues/34#issuecomment-864919215, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSBZXWDJRE5KD4V34BNZFLTT4HJLANCNFSM4RTQNIPA .

sree-kumar avatar Jun 23 '21 03:06 sree-kumar

Help again. Hunchentoot returns "Checkbox" items separately. For example,

<input type=checkbox name=vehicle value=Car>    Car
<input type=checkbox name=vehicle value=Bike>    Bike
<input type=checkbox name=vehicle value=Cycle>    Cycle

And the request object is something like: (vehicle . Car) (vehicle . Cycle) Is it possible to get a single list of selected items? Thanks in advance.

Update: I saw this answer in stack overflow. But they are dealing with only check boxes.

sree-kumar avatar Jun 24 '21 06:06 sree-kumar

Hey @sree-kumar, I find that writing HTML in the form of s-expressions is more difficult too, and not often necessary. It is mainly necessary when we generate it from a program, not really when we write it by hand. What if you wrote HTML with Djula or Ten instead? You'll be able to copy snippets (even start with ready-to-use templates, for example see Bulma templates) and find help more easily. Best,

vindarel avatar Jun 24 '21 09:06 vindarel

Sorry, I think you got my question wrong. I am asking about handling request information (GET and POST) in Hunchentoot. Since, I am a beginner, I would like to do everything myself so that I understand the basics. Once I am comfortable, I shall look into the templates you have suggested. By the way, I looked into Bulma Templates, but found it difficult for now.

sree-kumar avatar Jun 24 '21 10:06 sree-kumar

@vindarel, I have gone through your lisp journey post about introducing default-parameter-type.

Could please explain on that? Thanks.

sree-kumar avatar Jun 24 '21 10:06 sree-kumar

I solved the problem by adding,

((vehicle :parameter-type 'list))  

from this link Thanks for your support.

sree-kumar avatar Jun 24 '21 11:06 sree-kumar