PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: phoenixframework/phoenix_html (elixir)

Issue:
image_tag?
Would you be interested in an `image_tag` function? I'm imagining a thin wrapper around content tag that takes the first argument as a binary and sets the `src`. This seems like a pretty common use case to support.

I'm happy to implement it just didn't want to do the work if you weren't interested.

Pull request:
Add img/2 function for img tags
Fixes #129 

I wasn't sure if I should go with `img` or `img_tag`. The `button/2` function doesn't have `_tag`, nor does `form_for`. I think personally I prefer it without the unnecessary `_tag` but I could argue either way!

Patch:
diff --git a/lib/phoenix_html/tag.ex b/lib/phoenix_html/tag.ex
index 0ec3c78..ad0b024 100644
--- a/lib/phoenix_html/tag.ex
+++ b/lib/phoenix_html/tag.ex
@@ -244,4 +244,20 @@ defmodule Phoenix.HTML.Tag do
     tag :meta, charset: "UTF-8", name: "csrf-token", content: get_csrf_token(),
                'csrf-param': @csrf_param, 'method-param': @method_param
   end
+
+  @doc """
+  Generates an img tag with a src.
+
+  ## Examples
+
+      img(user.photo_path)
+      <img src="photo.png">
+
+      img(user.photo, class: "image")
+      <img src="smile.png" class="image">
+  """
+  def img(src, opts \\ []) do
+    opts = Keyword.merge([src: src], opts)
+    tag(:img, opts)
+  end
 end
diff --git a/priv/static/phoenix_html.js b/priv/static/phoenix_html.js
index 9c0ccf6..287f426 100644
--- a/priv/static/phoenix_html.js
+++ b/priv/static/phoenix_html.js
@@ -7,12 +7,22 @@ function isLinkToSubmitParent(element) {
   return isLinkTag && shouldSubmitParent;
 }
 
+function getClosestForm(element) {
+  while (element && element !== document && element.nodeType === Node.ELEMENT_NODE) {
+    if (element.tagName === 'FORM') {
+      return element;
+    }
+    element = element.parentNode;
+  }
+  return null;
+}
+
 function didHandleSubmitLinkClick(element) {
   while (element && element.getAttribute) {
     if (isLinkToSubmitParent(element)) {
       var message = element.getAttribute('data-confirm');
       if (message === null || confirm(message)) {
-        element.parentNode.submit();
+        getClosestForm(element).submit();
       };
       return true;
     } else {


Test patch:
diff --git a/test/phoenix_html/tag_test.exs b/test/phoenix_html/tag_test.exs
index d81bdae..122e1bc 100644
--- a/test/phoenix_html/tag_test.exs
+++ b/test/phoenix_html/tag_test.exs
@@ -91,6 +91,13 @@ defmodule Phoenix.HTML.TagTest do
            "<p>hello world</p>"
   end
 
+  test "img_tag" do
+    assert img("user.png") |> safe_to_string() == ~s(<img src="user.png">)
+
+    assert img("user.png", [class: "big"]) |> safe_to_string() ==
+      ~s(<img class="big" src="user.png">)
+  end
+
   test "form_tag for get" do
     assert safe_to_string(form_tag("/", method: :get)) ==
            ~s(<form accept-charset="UTF-8" action="/" method="get">) <>