nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: djc/askama
Pull request #801 (2023-03-28 07:41:01)

Update comrak to 0.17


Patch:
diff --git a/askama/Cargo.toml b/askama/Cargo.toml
index 62dfe4b..95554da 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.16", optional = true, default-features = false }
+comrak = { version = "0.17", 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 }
diff --git a/askama/src/filters/mod.rs b/askama/src/filters/mod.rs
index f76a463..642641a 100644
--- a/askama/src/filters/mod.rs
+++ b/askama/src/filters/mod.rs
@@ -377,12 +377,13 @@ where
             relaxed_tasklist_matching: false,
         },
         render: ComrakRenderOptions {
-            unsafe_: false,
             escape: true,
             // default:
             hardbreaks: false,
             github_pre_lang: false,
+            full_info_string: false,
             width: 0,
+            unsafe_: false,
             list_style: ListStyleType::Dash,
         },
     };


Test patch:
diff --git a/testing/Cargo.toml b/testing/Cargo.toml
index 8a68345..6e973a4 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.16", default-features = false, optional = true }
+comrak = { version = "0.17", default-features = false, optional = true }
 serde_json = { version = "1.0", optional = true }
 
 [dev-dependencies]
Repository: djc/askama
Pull request #822 (2023-06-10 03:14:48)

Allow macros to be defined and called without arguments
This PR proposes a shorthand for defining and calling macros when using them as a reusable substitute for variables assigned complex values (e.g. string literals with or without newline escapes). The use-case is formatting - from my experience it's easier to visually parse a `macro`-`endmacro` block than a multiline variable assignment.

I might be alone in that regard, though - opinions?


Patch:
diff --git a/askama_derive/src/parser/node.rs b/askama_derive/src/parser/node.rs
index fc6860e..8c122af 100644
--- a/askama_derive/src/parser/node.rs
+++ b/askama_derive/src/parser/node.rs
@@ -133,12 +133,13 @@ fn block_call(i: &str) -> IResult<&str, Node<'_>> {
         cut(tuple((
             opt(tuple((ws(identifier), ws(tag("::"))))),
             ws(identifier),
-            ws(Expr::parse_arguments),
+            opt(ws(Expr::parse_arguments)),
             opt(expr_handle_ws),
         ))),
     ));
     let (i, (pws, _, (scope, name, args, nws))) = p(i)?;
     let scope = scope.map(|(scope, _)| scope);
+    let args = args.unwrap_or_default();
     Ok((i, Node::Call(Ws(pws, nws), scope, name, args)))
 }
 
@@ -415,7 +416,7 @@ fn block_macro<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, Node<'a>> {
         ws(keyword("macro")),
         cut(tuple((
             ws(identifier),
-            ws(parameters),
+            opt(ws(parameters)),
             opt(expr_handle_ws),
             |i| tag_block_end(i, s),
         ))),
@@ -435,6 +436,8 @@ fn block_macro<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, Node<'a>> {
 
     assert_ne!(name, "super", "invalid macro name 'super'");
 
+    let params = params.unwrap_or_default();
+
     Ok((
         i,
         Node::Macro(


Test patch:
diff --git a/testing/templates/macro-no-args.html b/testing/templates/macro-no-args.html
new file mode 100644
index 0000000..b70ee8c
--- /dev/null
+++ b/testing/templates/macro-no-args.html
@@ -0,0 +1,21 @@
+1
+
+{%- macro empty -%}
+the best thing
+{%- endmacro -%}
+
+1
+
+{%- call empty() -%}
+
+1
+
+{%- macro whole() -%}
+we've ever done
+{%- endmacro -%}
+
+11
+
+{%- call whole -%}
+
+11
diff --git a/testing/tests/macro.rs b/testing/tests/macro.rs
index 6b0eca5..7e910a9 100644
--- a/testing/tests/macro.rs
+++ b/testing/tests/macro.rs
@@ -12,6 +12,16 @@ fn test_macro() {
     assert_eq!(t.render().unwrap(), "12foo foo foo34foo foo5");
 }
 
+#[derive(Template)]
+#[template(path = "macro-no-args.html")]
+struct MacroNoArgsTemplate;
+
+#[test]
+fn test_macro_no_args() {
+    let t = MacroNoArgsTemplate;
+    assert_eq!(t.render().unwrap(), "11the best thing111we've ever done11");
+}
+
 #[derive(Template)]
 #[template(path = "import.html")]
 struct ImportTemplate<'a> {