Skip to content

parse error with <style> tag #4

@dermetfan

Description

@dermetfan

I decided to try ructe for a small web project.

This is a reduced sample that should suffice to reproduce the problem.

main.rs:

include!(concat!(env!("OUT_DIR"), "/templates.rs"));

fn main() {
    templates::style(&mut std::io::stdout()).unwrap();
}

style.rs.html:

@()

<html>
<head>
<style>
#content {
    color: red;
}
</style>
</head>

<body>
<div id="content">Content!</div>
</body>
</html>

This results in a compilation error:

error[E0425]: unresolved name `templates::style`
 --> src/main.rs:4:5
  |
4 |     templates::style(&mut std::io::stdout()).unwrap();
  |     ^^^^^^^^^^^^^^^^

A more informative message is found in target/debug/build/<project>/output:

cargo:warning=Template parse error Eof in "/path/to/project/ructe-issue-3/templates/style.rs.html": "{\n    color: red;\n}\n</style>\n</head>\n\n<body>\n<div id=\"content\">Content!</div>\n</body>\n</html>\n"

The templates compiles if I remove the content of the <style>-tag.

My guess would be that ructe is confused by the curly braces in CSS, as the error message reports an Eof parse error at the first {.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions