Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions functions/create-issue/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ pub struct Quote {
pub author: String,
#[serde(rename = "authorDescription")]
pub author_description: String,
#[serde(rename = "authorUrl")]
pub author_url: String,
#[serde(rename = "authorUrl", skip_serializing_if = "Option::is_none")]
pub author_url: Option<String>,
}

#[derive(Deserialize, Serialize, Debug, Clone)]
Expand Down
15 changes: 7 additions & 8 deletions functions/create-issue/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,17 @@
Ok(Self)
}

pub fn render_newsletter(
&self,
issue_number: u32,
quote: &Quote,
book: &Book,
primary_link: &Link,
secondary_links: &[&Link],
extra_links: &[&Link],
extra_content_title: &str,
sponsor: Option<&Sponsor>,
) -> Result<String> {

Check warning on line 157 in functions/create-issue/src/template.rs

View workflow job for this annotation

GitHub Actions / clippy

this function has too many arguments (9/7)

warning: this function has too many arguments (9/7) --> functions/create-issue/src/template.rs:147:5 | 147 | / pub fn render_newsletter( 148 | | &self, 149 | | issue_number: u32, 150 | | quote: &Quote, ... | 156 | | sponsor: Option<&Sponsor>, 157 | | ) -> Result<String> { | |_______________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#too_many_arguments = note: `#[warn(clippy::too_many_arguments)]` on by default
let mut context = Context::new();

context.insert("issue_number", &issue_number);
Expand Down Expand Up @@ -219,7 +219,7 @@
text: "Computers are useless. They can only give you answers".to_string(),
author: "Pablo Picasso".to_string(),
author_description: "Artist".to_string(),
author_url: "https://en.wikipedia.org/wiki/Pablo_Picasso".to_string(),
author_url: Some("https://en.wikipedia.org/wiki/Pablo_Picasso".to_string()),
};

let book = Book {
Expand Down Expand Up @@ -519,28 +519,28 @@
}

// Test both naming conventions to understand which one Tera uses
let test_desc_rust = r#"{{ quote.author_description }}"#;
let test_desc_rust = r#"{{ quote.authorDescription }}"#;
let result_desc_rust = Tera::one_off(test_desc_rust, &full_context, false);
match result_desc_rust {
Ok(rendered) => println!("Rust field name works: {}", rendered),
Err(e) => println!("Rust field name failed: {}", e),
}

let test_desc_json = r#"{{ quote.author_description }}"#;
let test_desc_json = r#"{{ quote.authorDescription }}"#;
let result_desc = Tera::one_off(test_desc_json, &full_context, false);
match result_desc {
Ok(rendered) => println!("Description works: {}", rendered),
Err(e) => println!("Description failed: {}", e),
}

let test2b = r#"{{ quote.author_url }}"#;
let test2b = r#"{{ quote.authorUrl }}"#;
let result2b = Tera::one_off(test2b, &full_context, false);
match result2b {
Ok(rendered) => println!("Test 2b works: {}", rendered),
Err(e) => println!("Test 2b failed: {}", e),
}

let test2 = r#"> — [{{ quote.author }}]({{ quote.author_url }})"#;
let test2 = r#"> — [{{ quote.author }}]({{ quote.authorUrl }})"#;
let result2 = Tera::one_off(test2, &full_context, false);
match result2 {
Ok(rendered) => println!("Test 2 works:\n{}", rendered),
Expand All @@ -549,8 +549,8 @@

// Test just the beginning of our actual template
let partial_template = r#"Hello World
> "{{ quote.text }}"
> — {{ quote.author }}, {{ quote.author_description }}"#;
> "{{ quote.text }}"
> — {{ quote.author }}, {{ quote.authorDescription }}"#;

let partial_result = Tera::one_off(partial_template, &full_context, false);
match partial_result {
Expand All @@ -577,7 +577,6 @@
assert!(rendered.contains("Building Microservices"));
assert!(rendered.contains("An Interactive Guide to SVG Paths"));
assert!(rendered.contains("{{ subscriber.metadata.first_name }}"));
assert!(rendered.contains("{{ subscribe_form }}"));
}
Err(e) => {
println!("Template rendering failed: {}", e);
Expand Down
Loading