Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is the behavior of the ~figcaption argument to Html.figure correct? #110

Open
gmcninch opened this issue Apr 16, 2020 · 0 comments
Open

Comments

@gmcninch
Copy link

> opam list cow 
[...]
cow.2.4.0  2.4.0       Caml on the Web

I get the following:

open Cow;;

Uri.of_string "foo.jpg"
|> Html.img
|> Html.figure ~figcaption:(Html.string "caption")
|> Html.to_string;;
- : string =
"<!DOCTYPE html>\n<figure><figcaption>caption<img src=\"foo.jpg\"/></figcaption></figure>"

Which doesn't seem to be what I'd expect.

Well, I guess the oddness is that really, figcaption is not an attribute, but a node.

(For what it is worth, I solved this for my use-case by defining

let figcaption text =
  Html.string text
  |> Html.tag "figcaption"

and then doing something like

let my_image = Uri.of_string "foo.jpg"
                 |> Html.img
in
Html.list [my_image; figcaption "caption"]
|> Html.figure
|> Html.to_string;;
- : string =
"<!DOCTYPE html>\n<figure><img src=\"foo.jpg\"/><figcaption>caption</figcaption></figure>"

I just thought I'd report the issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant