Skip to content

Commit

Permalink
fix other problems with askama's main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
msrd0 committed Jun 9, 2021
1 parent b54e4f9 commit f8f66f4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
7 changes: 1 addition & 6 deletions codegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use bit_vec::BitVec;
use linked_hash_map::LinkedHashMap;
use num_format::{Locale, ToFormattedString};
use std::{
borrow::Borrow,
cmp::Ordering,
collections::BTreeSet,
convert::TryInto,
Expand All @@ -31,12 +32,6 @@ const CHAR_RANGES: &[(char, char)] = &[
const MIN_ROWS: u32 = 4;
const MAX_ROWS: u32 = 20;

mod filters {
pub fn chunks<'a>(src: &'a [u8], size: &usize) -> askama::Result<Vec<&'a [u8]>> {
Ok(src.chunks(*size).collect())
}
}

#[derive(Template)]
#[template(path = "src.rs.j2", escape = "none")]
struct RustSource<'a> {
Expand Down
2 changes: 1 addition & 1 deletion codegen/templates/src.rs.j2
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub const FONT_{{ font.width }}x{{ font.height }}{% if font.bold %}_BOLD{% endif
bitmap: ImageRaw::new_binary(
// {{ font.img_width }} x {{ font.img_height }} ({{ font.bitmap_len }})
&[
{%- for chunk in font.bitmap | chunks(16) %}
{%- for chunk in font.bitmap.chunks(16) %}
{% for byte in chunk %}0x{{ "{:02x}"|format(byte) }}{% if !loop.last %}, {% endif %}{% endfor %}
{%- if !loop.last %},{% endif %}
{%- endfor %}
Expand Down
4 changes: 2 additions & 2 deletions codegen/templates/tests.rs.j2
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ test_font! {
height: {{ font.height }},
a_pattern: &[
{%- for y in 0..font.height %}
"{{ font.glyph('a').mock_line(y) }}#{{ font.glyph('a').mock_line_inverted(y) }}#"
"{{ font.glyph('a'.borrow()).mock_line(y) }}#{{ font.glyph('a'.borrow()).mock_line_inverted(y) }}#"
{%- if !loop.last %},{% endif %}
{%- endfor %}
],
Expand All @@ -117,7 +117,7 @@ test_font! {
{%- endfor %}
fallback_pattern: &[
{%- for y in 0..font.height %}
"{{ font.glyph('?').mock_line(y) }}{{ font.glyph('?').mock_line(y) }}{{ font.glyph('?').mock_line(y) }}"
"{{ font.glyph('?'.borrow()).mock_line(y) }}{{ font.glyph('?'.borrow()).mock_line(y) }}{{ font.glyph('?'.borrow()).mock_line(y) }}"
{%- if !loop.last %},{% endif %}
{%- endfor %}
]
Expand Down

0 comments on commit f8f66f4

Please sign in to comment.