nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: djc/askama
Pull request #960 (2024-01-26 04:06:19)

build(deps): update comrak requirement from 0.20 to 0.21
Updates the requirements on comrak to permit the latest version.


Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/askama/Cargo.toml b/askama/Cargo.toml
index 26be2a4..7b9575a 100644
--- a/askama/Cargo.toml
+++ b/askama/Cargo.toml
@@ -41,7 +41,7 @@ mime_guess = []
 [dependencies]
 askama_derive = { version = "0.12.0", path = "../askama_derive" }
 askama_escape = { version = "0.10.3", path = "../askama_escape" }
-comrak = { version = "0.20", optional = true, default-features = false }
+comrak = { version = "0.21", optional = true, default-features = false }
 dep_humansize = { package = "humansize", version = "2", optional = true }
 dep_num_traits = { package = "num-traits", version = "0.2.6", optional = true }
 percent-encoding = { version = "2.1.0", optional = true }


Test patch:
diff --git a/testing/Cargo.toml b/testing/Cargo.toml
index 20ef72a..6c7b958 100644
--- a/testing/Cargo.toml
+++ b/testing/Cargo.toml
@@ -14,7 +14,7 @@ markdown = ["comrak", "askama/markdown"]
 
 [dependencies]
 askama = { path = "../askama", version = "0.12" }
-comrak = { version = "0.20", default-features = false, optional = true }
+comrak = { version = "0.21", default-features = false, optional = true }
 phf = { version = "0.11", features = ["macros" ]}
 serde_json = { version = "1.0", optional = true }
Repository: djc/askama
Pull request #980 (2024-03-07 15:19:14)

Implement `Template` for `&Template`
`Template` does not have methods that alter `self` in any way, so a reference to a `Template` can implement `Template`, too.

This is a breaking change, because a user could have manually added `impl Template for &MyStruct {…}`.


Patch:
diff --git a/askama/src/lib.rs b/askama/src/lib.rs
index a98989e..23414f6 100644
--- a/askama/src/lib.rs
+++ b/askama/src/lib.rs
@@ -115,6 +115,29 @@ pub trait Template: fmt::Display {
     const MIME_TYPE: &'static str;
 }
 
+impl<T: Template + ?Sized> Template for &T {
+    #[inline]
+    fn render_into(&self, writer: &mut (impl std::fmt::Write + ?Sized)) -> Result<()> {
+        T::render_into(self, writer)
+    }
+
+    #[inline]
+    fn render(&self) -> Result<String> {
+        T::render(self)
+    }
+
+    #[inline]
+    fn write_into(&self, writer: &mut (impl std::io::Write + ?Sized)) -> std::io::Result<()> {
+        T::write_into(self, writer)
+    }
+
+    const EXTENSION: Option<&'static str> = T::EXTENSION;
+
+    const SIZE_HINT: usize = T::SIZE_HINT;
+
+    const MIME_TYPE: &'static str = T::MIME_TYPE;
+}
+
 /// Object-safe wrapper trait around [`Template`] implementers
 ///
 /// This trades reduced performance (mostly due to writing into `dyn Write`) for object safety.


Test patch:
diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs
index ba806e2..bc552cd 100644
--- a/testing/tests/simple.rs
+++ b/testing/tests/simple.rs
@@ -504,3 +504,23 @@ fn test_mixed_case() {
     let template = MixedCase { xY: "foo" };
     assert_eq!(template.render().unwrap(), "foo");
 }
+
+#[allow(non_snake_case)]
+#[derive(askama::Template)]
+#[template(source = "Hello, {{ user }}!", ext = "txt")]
+struct Referenced {
+    user: &'static str,
+}
+
+#[test]
+#[allow(clippy::needless_borrows_for_generic_args)]
+fn test_referenced() {
+    fn template_to_string(template: impl Template) -> String {
+        template.to_string()
+    }
+
+    let template = Referenced { user: "person" };
+    assert_eq!(template_to_string(&&template), "Hello, person!");
+    assert_eq!(template_to_string(&template), "Hello, person!");
+    assert_eq!(template_to_string(template), "Hello, person!");
+}
Repository: djc/askama
Pull request #997 (2024-04-01 04:32:58)

build(deps): update comrak requirement from 0.21 to 0.22
Updates the requirements on comrak to permit the latest version.


Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/askama/Cargo.toml b/askama/Cargo.toml
index c05fecf..dd36ae5 100644
--- a/askama/Cargo.toml
+++ b/askama/Cargo.toml
@@ -37,7 +37,7 @@ mime_guess = []
 [dependencies]
 askama_derive = { version = "0.13", path = "../askama_derive" }
 askama_escape = { version = "0.10.3", path = "../askama_escape" }
-comrak = { version = "0.21", optional = true, default-features = false }
+comrak = { version = "0.22", optional = true, default-features = false }
 dep_humansize = { package = "humansize", version = "2", optional = true }
 dep_num_traits = { package = "num-traits", version = "0.2.6", optional = true }
 percent-encoding = { version = "2.1.0", optional = true }


Test patch:
diff --git a/testing/Cargo.toml b/testing/Cargo.toml
index 9d6c673..3b33dbd 100644
--- a/testing/Cargo.toml
+++ b/testing/Cargo.toml
@@ -14,7 +14,7 @@ markdown = ["comrak", "askama/markdown"]
 
 [dependencies]
 askama = { path = "../askama", version = "0.13" }
-comrak = { version = "0.21", default-features = false, optional = true }
+comrak = { version = "0.22", default-features = false, optional = true }
 phf = { version = "0.11", features = ["macros" ]}
 serde_json = { version = "1.0", optional = true }
Repository: djc/askama
Pull request #1102 (2024-10-09 14:56:40)

Fix scope leak with for nested inside if let
cc @anna-is-cute looks like I fumbled a push to your original branch for #1101, but here's a PR with a fix.


Patch:
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index 7d29524..47ec57c 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -545,6 +545,7 @@ impl<'a> Generator<'a> {
         }
 
         buf.writeln("}")?;
+        self.locals.pop();
 
         Ok(flushed + ((size_hint1 * 3) + size_hint2) / 2)
     }


Test patch:
diff --git a/testing/templates/if-let-with-for.html b/testing/templates/if-let-with-for.html
new file mode 100644
index 0000000..b0de7f9
--- /dev/null
+++ b/testing/templates/if-let-with-for.html
@@ -0,0 +1,11 @@
+{%- if let Some(thing) = thing -%}
+    {%- for item in thing.items -%}
+        {{ item }}
+    {%- endfor -%}
+{%- endif -%}
+
+{%- if let Some(thing) = thing -%}
+    {%- for item in thing.items -%}
+        {{ item }}
+    {%- endfor -%}
+{%- endif -%}
diff --git a/testing/tests/if_let.rs b/testing/tests/if_let.rs
index d383418..da5428b 100644
--- a/testing/tests/if_let.rs
+++ b/testing/tests/if_let.rs
@@ -128,3 +128,26 @@ fn test_elif() {
     assert_eq!(Elif { s: None }.render().unwrap(), "empty");
     assert_eq!(Elif { s: Some("tada") }.render().unwrap(), "tada");
 }
+
+#[derive(Template)]
+#[template(path = "if-let-with-for.html")]
+struct IfLetWithForTemplate {
+    thing: Option<IfLetWithForTemplateThing>,
+}
+
+struct IfLetWithForTemplateThing {
+    items: Vec<usize>,
+}
+
+#[test]
+fn test_if_let_with_for() {
+    let s = IfLetWithForTemplate {
+        thing: Some(IfLetWithForTemplateThing {
+            items: vec![1, 2, 3],
+        }),
+    };
+    assert_eq!(s.render().unwrap(), "123123");
+
+    let t = IfLetWithForTemplate { thing: None };
+    assert_eq!(t.render().unwrap(), "");
+}