Skip to content

Commit

Permalink
Fix default template when details are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
msrd0 committed Sep 19, 2023
1 parent 69a3354 commit fa7eaef
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/README.j2
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{# this is the default template used when the user does not specify one #}

{%- if crate is defined -%}
{%- if crate -%}
# {{ crate }}
{%- if license is defined %} ![License: {{ license }}](https://img.shields.io/badge/license-{{ license | replace("-", "--") | urlencode }}-blue)
{%- if license %} ![License: {{ license }}](https://img.shields.io/badge/license-{{ license | replace("-", "--") | urlencode }}-blue)
{%- else %} ![License](https://img.shields.io/crates/l/{{ crate | urlencode }})
{%- endif %}
{%- if crate is defined %} [![{{ crate }} on crates.io](https://img.shields.io/crates/v/{{ crate | urlencode }})](https://crates.io/crates/{{ crate | urlencode }})
{%- if crate %} [![{{ crate }} on crates.io](https://img.shields.io/crates/v/{{ crate | urlencode }})](https://crates.io/crates/{{ crate | urlencode }})
{%- if target == "lib" %} [![{{ crate }} on docs.rs](https://docs.rs/{{ crate | urlencode }}/badge.svg)](https://docs.rs/{{ crate | urlencode }})
{%- endif %}
{%- endif %}
{%- if repository is defined %}
{%- if repository %}
{%- if repository_host == "github.com" %} [![Source Code Repository](https://img.shields.io/badge/Code-On%20GitHub-blue?logo=GitHub)]({{ repository }})
{%- elif repository_host is defined %} [![Source Code Repository](https://img.shields.io/badge/Code-On%20{{ repository_host | replace("-", "--") | urlencode }}-blue)]({{ repository }})
{%- elif repository_host %} [![Source Code Repository](https://img.shields.io/badge/Code-On%20{{ repository_host | replace("-", "--") | urlencode }}-blue)]({{ repository }})
{%- endif %}
{%- endif %}
{%- if rust_version is defined %} ![Rust Version: {{rust_version}}](https://img.shields.io/badge/rustc-{{ rust_version | urlencode }}-orange.svg)
{%- if rust_version %} ![Rust Version: {{rust_version}}](https://img.shields.io/badge/rustc-{{ rust_version | urlencode }}-orange.svg)
{%- endif %}
{%- endif %}

Expand Down
7 changes: 7 additions & 0 deletions tests/pass/default-template-no-details/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/pass/default-template-no-details/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "default_template_no_details"
version = "0.0.0"
publish = false
edition = "2021"

[lib]
path = "lib.rs"
4 changes: 4 additions & 0 deletions tests/pass/default-template-no-details/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# default_template_no_details ![License](https://img.shields.io/crates/l/default_template_no_details) [![default_template_no_details on crates.io](https://img.shields.io/crates/v/default_template_no_details)](https://crates.io/crates/default_template_no_details) [![default_template_no_details on docs.rs](https://docs.rs/default_template_no_details/badge.svg)](https://docs.rs/default_template_no_details)

This test ensures that the default template behaves well when there are no details (like description, license, rust-version etc) defined in the `Cargo.toml` file.

2 changes: 2 additions & 0 deletions tests/pass/default-template-no-details/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//! This test ensures that the default template behaves well when there are no details
//! (like description, license, rust-version etc) defined in the `Cargo.toml` file.

0 comments on commit fa7eaef

Please sign in to comment.