Skip to content

Commit

Permalink
Extends expects a string and nothing else
Browse files Browse the repository at this point in the history
  • Loading branch information
Kijewski authored and djc committed Jan 30, 2023
1 parent 071106d commit 63b98ec
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion askama_derive/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ fn find_used_templates(
while let Some((path, source)) = check.pop() {
for n in parse(&source, input.syntax)? {
match n {
Node::Extends(Expr::StrLit(extends)) => {
Node::Extends(extends) => {
let extends = input.config.find_template(extends, Some(&path))?;
let dependency_path = (path.clone(), extends.clone());
if dependency_graph.contains(&dependency_path) {
Expand Down
4 changes: 2 additions & 2 deletions askama_derive/src/heritage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::path::{Path, PathBuf};

use crate::config::Config;
use crate::parser::{Expr, Loop, Macro, Node};
use crate::parser::{Loop, Macro, Node};
use crate::CompileError;

pub(crate) struct Heritage<'a> {
Expand Down Expand Up @@ -58,7 +58,7 @@ impl Context<'_> {
while let Some(nodes) = nested.pop() {
for n in nodes {
match n {
Node::Extends(Expr::StrLit(extends_path)) if top => match extends {
Node::Extends(extends_path) if top => match extends {
Some(_) => return Err("multiple extend blocks found".into()),
None => {
extends = Some(config.find_template(extends_path, Some(path))?);
Expand Down
4 changes: 2 additions & 2 deletions askama_derive/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) enum Node<'a> {
Cond(Vec<Cond<'a>>, Ws),
Match(Ws, Expr<'a>, Vec<When<'a>>, Ws),
Loop(Loop<'a>),
Extends(Expr<'a>),
Extends(&'a str),
BlockDef(Ws, &'a str, Vec<Node<'a>>, Ws),
Include(Ws, &'a str),
Import(Ws, &'a str, &'a str),
Expand Down Expand Up @@ -985,7 +985,7 @@ fn block_for<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, Node<'a>> {
}

fn block_extends(i: &str) -> IResult<&str, Node<'_>> {
let (i, (_, name)) = tuple((ws(keyword("extends")), ws(expr_str_lit)))(i)?;
let (i, (_, name)) = tuple((ws(keyword("extends")), ws(str_lit)))(i)?;
Ok((i, Node::Extends(name)))
}

Expand Down

0 comments on commit 63b98ec

Please sign in to comment.