-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from GuillaumeGomez/top-level-nodes-errors
Generate better errors for top level nodes
- Loading branch information
Showing
7 changed files
with
128 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use rinja::Template; | ||
|
||
#[derive(Template)] | ||
#[template(source = r#" | ||
{% extends "let.html" %} | ||
{% extends "foo.html" %} | ||
"#, ext = "txt")] | ||
struct MyTemplate4; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |