mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-28 05:21:14 +00:00
Add UI tests for top level nodes
This commit is contained in:
parent
79e7331ccc
commit
27e12f083b
29
testing/tests/ui/blocks_below_top_level.rs
Normal file
29
testing/tests/ui/blocks_below_top_level.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use rinja::Template;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(source = r#"
|
||||
{% block bla %}
|
||||
{% extends "bla.txt" %}
|
||||
{% endblock %}
|
||||
"#, ext = "txt")]
|
||||
struct MyTemplate1;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(source = r#"
|
||||
{% block bla %}
|
||||
{% macro bla() %}
|
||||
{% endmacro %}
|
||||
{% endblock %}
|
||||
"#, ext = "txt")]
|
||||
struct MyTemplate2;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(source = r#"
|
||||
{% block bla %}
|
||||
{% import "bla.txt" as blue %}
|
||||
{% endblock %}
|
||||
"#, ext = "txt")]
|
||||
struct MyTemplate3;
|
||||
|
||||
fn main() {
|
||||
}
|
29
testing/tests/ui/blocks_below_top_level.stderr
Normal file
29
testing/tests/ui/blocks_below_top_level.stderr
Normal file
@ -0,0 +1,29 @@
|
||||
error: extends blocks are not allowed below top level
|
||||
--> MyTemplate1.txt:3:2
|
||||
" extends \"bla.txt\" %}\n{% endblock %}\n"
|
||||
--> tests/ui/blocks_below_top_level.rs:3:10
|
||||
|
|
||||
3 | #[derive(Template)]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: macro blocks are not allowed below top level
|
||||
--> MyTemplate2.txt:3:2
|
||||
" macro bla() %}\n{% endmacro %}\n{% endblo"...
|
||||
--> tests/ui/blocks_below_top_level.rs:11:10
|
||||
|
|
||||
11 | #[derive(Template)]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: import blocks are not allowed below top level
|
||||
--> MyTemplate3.txt:3:2
|
||||
" import \"bla.txt\" as blue %}\n{% endblock"...
|
||||
--> tests/ui/blocks_below_top_level.rs:20:10
|
||||
|
|
||||
20 | #[derive(Template)]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
|
10
testing/tests/ui/multiple_extends.rs
Normal file
10
testing/tests/ui/multiple_extends.rs
Normal file
@ -0,0 +1,10 @@
|
||||
use rinja::Template;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(source = r#"
|
||||
{% extends "let.html" %}
|
||||
{% extends "foo.html" %}
|
||||
"#, ext = "txt")]
|
||||
struct MyTemplate4;
|
||||
|
||||
fn main() {}
|
9
testing/tests/ui/multiple_extends.stderr
Normal file
9
testing/tests/ui/multiple_extends.stderr
Normal file
@ -0,0 +1,9 @@
|
||||
error: multiple extend blocks found
|
||||
--> MyTemplate4.txt:3:2
|
||||
" extends \"foo.html\" %}\n"
|
||||
--> tests/ui/multiple_extends.rs:3:10
|
||||
|
|
||||
3 | #[derive(Template)]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
|
Loading…
x
Reference in New Issue
Block a user