40ants / lisp-project-of-the-day

Here I'll post notes about Quicklisp projects. Also I publish them on Twitter account svetlyak40wt.
http://40ants.com/lisp-project-of-the-day/
BSD 2-Clause "Simplified" License
51 stars 6 forks source link

spinneret #34

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

spinneret

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

lispstudent commented 4 years ago

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.

svetlyak40wt commented 4 years ago

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

lispstudent commented 4 years ago

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.

sree-kumar commented 3 years ago

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

svetlyak40wt commented 3 years ago

@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>"
sree-kumar commented 3 years ago

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 commented 3 years ago

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.

vindarel commented 3 years ago

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,

sree-kumar commented 3 years ago

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 commented 3 years ago

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

Could please explain on that? Thanks.

sree-kumar commented 3 years ago

I solved the problem by adding,

((vehicle :parameter-type 'list))  

from this link Thanks for your support.