Keats / tera

A template engine for Rust based on Jinja2/Django
http://keats.github.io/tera/
MIT License
3.36k stars 280 forks source link

error while importing #903

Closed FatSquare closed 5 months ago

FatSquare commented 5 months ago

there is no much documentation about imports nor tests in the source code i tried making simple two files

<!-- index.html -->
<html>
    {% import "header.html" as header %}
    {{ header::head() }}
    <body>
        hello world
    </body>
</html>
<!-- header.html -->
{% macro head() %}
    <head>
        <title> title </title>
    </head>
{% endmacro head %}

and I got this error image

FatSquare commented 5 months ago

okay i fixed it. looks like the {% import %} statmetns needs to be at top level of the tml like

{% import "header.html" as header %}
<html>
    {{ header::head() }}
    <body>
        hello world
    </body>
</html>

but there is nothing that says that at the documentation. there is literally only 2 lines about import and they don't talk about this!