Skip to content

Commit

Permalink
Merge pull request #192 from Kijewski/pr-use-rinja
Browse files Browse the repository at this point in the history
generator: better macro hygiene
  • Loading branch information
GuillaumeGomez authored Oct 4, 2024
2 parents c98bc79 + 4d7a64f commit 441756b
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 216 deletions.
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[licenses]
version = 2
allow = ["Apache-2.0", "BSD-2-Clause", "MIT", "Unicode-DFS-2016"]
allow = ["Apache-2.0", "MIT", "MIT-0", "Unicode-DFS-2016"]
private = { ignore = true }

[[licenses.clarify]]
Expand Down
6 changes: 4 additions & 2 deletions rinja/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#![doc(hidden)]

use std::cell::Cell;
use std::fmt;
use std::iter::{Enumerate, Peekable};

// The re-exports are used in the generated code for macro hygiene. Even if the paths `::core` or
// `::std` are shadowed, the generated code will still be able to access the crates.
pub use {core, std};

use crate::filters::FastWritable;

pub struct TemplateLoop<I>
Expand Down
1 change: 1 addition & 0 deletions rinja/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

mod error;
pub mod filters;
#[doc(hidden)]
pub mod helpers;
mod html;

Expand Down
8 changes: 4 additions & 4 deletions rinja_derive/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use proc_macro2::Span;
#[cfg(feature = "config")]
use serde::Deserialize;

use crate::{CRATE, CompileError, FileInfo, OnceMap};
use crate::{CompileError, FileInfo, OnceMap};

#[derive(Debug)]
pub(crate) struct Config {
Expand Down Expand Up @@ -182,7 +182,7 @@ impl Config {
for (extensions, name) in DEFAULT_ESCAPERS {
escapers.push((
str_set(extensions),
format!("{CRATE}::filters::{name}").into(),
format!("rinja::filters::{name}").into(),
));
}

Expand Down Expand Up @@ -682,11 +682,11 @@ mod tests {
str_set(&[
"html", "htm", "j2", "jinja", "jinja2", "rinja", "svg", "xml"
]),
"::rinja::filters::Html".into()
"rinja::filters::Html".into()
),
(
str_set(&["md", "none", "txt", "yml", ""]),
"::rinja::filters::Text".into()
"rinja::filters::Text".into()
),
]);
}
Expand Down
Loading

0 comments on commit 441756b

Please sign in to comment.