Replies: 2 comments
-
You might have to explicitly pass the <!-- src/index.njk -->
{%- import "macros.njk" as macros -%}
<article>
{{ macros.field("name", "", "text", page) }}
</article> <!-- src/_includes/macros.njk -->
{% macro field(name, value="", type="text", page={}) %}
<div class="field">
<input type="{{ type }}" name="{{ name }}"
value="{{ value | escape }}" />
<!-- {{ page | dump(2) | safe }} -->
</div>
{% endmacro %}
OUTPUT<article>
<div class="field">
<input type="text" name="name" value="" />
<!-- {
"date": "2023-03-08T18:25:38.768Z",
"inputPath": "./src/index.njk",
"fileSlug": "",
"filePathStem": "/index",
"outputFileExtension": "html",
"templateSyntax": "njk",
"url": "/",
"outputPath": "www/index.html"
} -->
</div>
</article> |
Beta Was this translation helpful? Give feedback.
0 replies
-
Passing the What's the reason for |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was working with some nunjucks macros and when I tried to use
eleventy-plugin-i18n
inside of them, it used the fallback because it seens that thepage
variable wasundefined
.example.njk
output.html
Inside layouts it works fine, but I wonder if it is posible to acces to the
page
variable from a macro or I'm doing something wrong.Beta Was this translation helpful? Give feedback.
All reactions