Merge pull request 'Add test for empty topic and fix broken template logic' (#31) from fix-template into main

Reviewed-on: #31
This commit is contained in:
Anthony J. Martinez 2021-05-06 14:14:42 +00:00
commit 0891896ae3
4 changed files with 16 additions and 5 deletions

2
Cargo.lock generated
View File

@ -26,7 +26,7 @@ checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b"
[[package]]
name = "arse"
version = "0.8.0"
version = "0.8.1"
dependencies = [
"anyhow",
"clap",

View File

@ -1,6 +1,6 @@
[package]
name = "arse"
version = "0.8.0"
version = "0.8.1"
authors = ["Anthony Martinez"]
edition = "2018"
license = "MIT OR Apache-2.0"

View File

@ -207,4 +207,17 @@ Super Wow!
assert!(page.contains("super useful"));
assert!(page.contains("Super Wow!"));
}
#[test]
fn check_render_empty_topic() {
let dir = tempfile::tempdir().unwrap();
let mut src: &[u8] = b"Site Name\nAuthor Name\nOne, Two, Three, And More\nadmin\n";
let config = AppConfig::generate(&dir, &mut src).unwrap();
let config = Arc::new(config);
let engine = Engine::new(config);
let page = engine.render_topic("one").unwrap();
assert!(page.contains("Coming Soon"));
}
}

View File

@ -32,15 +32,13 @@ pub(crate) const TEMPLATE: &str = r#"
<main>
{% if post %}
{{ post }}
{% elif posts %}
{% if posts | length == 0 %}
{% elif posts | length < 1 %}
<h3>Coming Soon!</h3>
{% else %}
{%- for post in posts %}
{{ post }}
{%- endfor -%}
{% endif %}
{% endif %}
</main>
<footer>
<p>&#169; {{ site.author }}</p>