weavejester / hiccup

Fast library for rendering HTML in Clojure
http://weavejester.github.io/hiccup
Eclipse Public License 1.0
2.68k stars 175 forks source link

Parameters for iframe src attribute #200

Closed jrootham closed 1 year ago

jrootham commented 1 year ago

There is no obvious way to put parameters on the src attribute of an iframe.

weavejester commented 1 year ago

I'm afraid I don't understand the question. Can you give an example of the HTML you're trying to produce?

jrootham commented 1 year ago
weavejester commented 1 year ago

That would be written in Hiccup as:

[:iframe {:src "page.html?arg1=1&arg2=a"}]
jrootham commented 1 year ago

Yes, that is possible. I was hoping to write [:iframe {:src "page.html" :query-params {"arg1" "1", "arg2" "a"}}]

I was thinking that this would be more like form-to, but I just realized that the parameter string there is constructed by the browser, so this would be a new thing for hiccup.

I would still like to propose it as a new feature. Is there a particular format you would like to see proposed features described in?

jrootham commented 1 year ago

In particular, would you like me to do a pull request?

weavejester commented 1 year ago

You can use the hiccup.util/url function for that:

(require '[hiccup.core :as h])
(require '[hiccup.util :as u])

(h/html [:iframe {:src (u/url "page.html" {:arg1 1, :arg2 "a"})}])

With regards to pull requests, it's usually best to first raise an issue so the feature can be discussed, before starting coding.

jrootham commented 1 year ago

D'oh, I obviously failed to RTFM.

jrootham commented 1 year ago

See RTFM