mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-01 06:51:15 +00:00
Fix formatting with cargo fmt
This commit is contained in:
parent
f29c12f469
commit
6aa485ec08
@ -409,7 +409,8 @@ pub mod actix_web {
|
||||
use self::mime_guess::get_mime_type;
|
||||
|
||||
pub fn respond(t: &super::Template, ext: &str) -> Result<HttpResponse, Error> {
|
||||
let rsp = t.render()
|
||||
let rsp = t
|
||||
.render()
|
||||
.map_err(|_| ErrorInternalServerError("Template parsing error"))?;
|
||||
let ctype = get_mime_type(ext).to_string();
|
||||
Ok(HttpResponse::Ok().content_type(ctype.as_str()).body(rsp))
|
||||
|
@ -147,7 +147,8 @@ impl<'a> Generator<'a> {
|
||||
buf.writeln("fn modify(self, res: &mut ::askama::iron::Response) {");
|
||||
buf.writeln("res.body = Some(Box::new(self.render().unwrap().into_bytes()));");
|
||||
|
||||
let ext = self.input
|
||||
let ext = self
|
||||
.input
|
||||
.path
|
||||
.extension()
|
||||
.map_or("", |s| s.to_str().unwrap_or(""));
|
||||
@ -429,14 +430,16 @@ impl<'a> Generator<'a> {
|
||||
let def = if let Some(s) = match scope {
|
||||
None => match level {
|
||||
AstLevel::Nested(s) => s,
|
||||
_ => None
|
||||
_ => None,
|
||||
},
|
||||
s => s,
|
||||
} {
|
||||
let path = ctx.imports
|
||||
let path = ctx
|
||||
.imports
|
||||
.get(s)
|
||||
.unwrap_or_else(|| panic!("no import found for scope '{}'", s));
|
||||
let mctx = self.contexts
|
||||
let mctx = self
|
||||
.contexts
|
||||
.get(path)
|
||||
.unwrap_or_else(|| panic!("context for '{:?}' not found", path));
|
||||
mctx.macros
|
||||
@ -471,7 +474,8 @@ impl<'a> Generator<'a> {
|
||||
|
||||
fn handle_include(&mut self, ctx: &'a Context, buf: &mut Buffer, ws: WS, path: &str) {
|
||||
self.flush_ws(buf, ws);
|
||||
let path = self.input
|
||||
let path = self
|
||||
.input
|
||||
.config
|
||||
.find_template(path, Some(&self.input.path));
|
||||
let src = get_template_source(&path);
|
||||
@ -539,7 +543,8 @@ impl<'a> Generator<'a> {
|
||||
self.super_block = Some(cur);
|
||||
|
||||
// Get the block definition from the heritage chain
|
||||
let heritage = self.heritage
|
||||
let heritage = self
|
||||
.heritage
|
||||
.as_ref()
|
||||
.unwrap_or_else(|| panic!("no block ancestors available"));
|
||||
let (ctx, def) = heritage.blocks[cur.0]
|
||||
|
@ -103,7 +103,8 @@ impl<'a> Heritage<'a> {
|
||||
mut ctx: &'n Context<'n>,
|
||||
contexts: &'n HashMap<&'n PathBuf, Context<'n>>,
|
||||
) -> Heritage<'n> {
|
||||
let mut blocks: BlockAncestry<'n> = ctx.blocks
|
||||
let mut blocks: BlockAncestry<'n> = ctx
|
||||
.blocks
|
||||
.iter()
|
||||
.map(|(name, def)| (*name, vec![(ctx, *def)]))
|
||||
.collect();
|
||||
|
@ -27,8 +27,10 @@ impl Config {
|
||||
let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
let filename = root.join(CONFIG_FILE_NAME);
|
||||
if filename.exists() {
|
||||
Self::from_str(&fs::read_to_string(&filename)
|
||||
.expect(&format!("unable to read {}", filename.to_str().unwrap())))
|
||||
Self::from_str(
|
||||
&fs::read_to_string(&filename)
|
||||
.expect(&format!("unable to read {}", filename.to_str().unwrap())),
|
||||
)
|
||||
} else {
|
||||
Self::from_str("")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user