eta-dev / eta

Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript
https://eta.js.org
MIT License
1.35k stars 60 forks source link

Pass entire it context under partial #272

Closed multivoltage closed 4 months ago

multivoltage commented 5 months ago

description request

I need to get myVar from it context in a templated called by parent with <%~ include("./footer", { it: allEntireIt }) %> and use inside footer <%~ it.myVar %>

proposal solution

Pass entire all contex down the three

alternative

Maybe this is not a feature and there is already a method for this goal

multivoltage commented 5 months ago

@nebrelbug I think solution is

<%~ include("./footer", { ...it }) %>

Maybe I can open a PR for improve docs? Probably for you and people using template engine is "easy" to imaginate spread operator, but for me I spent 1 entire day :)

nebrelbug commented 4 months ago

@multivoltage glad you got it working! Another possibility is

<%~ include("./footer", it) %>

I'd appreciate a PR!