weavejester/hiccup

Parameters for iframe src attribute

jrootham opened this issue · 8 comments

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

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

<iframe src="page.html?arg1=1&arg2=a"></iframe>

That would be written in Hiccup as:

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

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?

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

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.

D'oh, I obviously failed to RTFM.

See RTFM