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

Adding childrens in include/includeAsync #280

Closed drylian closed 2 months ago

drylian commented 3 months ago

Is your feature request related to a problem? Please describe. I wouldn't say it's a problem

Describe the solution you'd like A clear and concise description of what you want to happen. But it would be interesting to have added it, I really liked eta because of its ability to be much superior to ejs (which I used, but it had a lot of bugs and I couldn't really explore its potential), but in eta I I'm able to use everything I thought of doing in ejs, there's one thing missing to make this perfect, which I don't know if it would be possible, plus the ability to add children to an include/includeAsync, honestly it would be perfect if that were possible, it could be explored many things with this addition

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here. This is a simple example, a few more things I had to adapt so that down.eta would be small, but I could make many templates of these types, if I had a child here I would be able to take advantage of more of the settings

Top.eta image Down.eta image Result image

nebrelbug commented 3 months ago

Hi @drylian! Thanks for the kind feedback:)

If I understand your question correctly, it sounds like you're wondering about passing part of a template into an include. Have you considered using layouts?

drylian commented 3 months ago

The explanation in the v3 documentation is very vague about how the layout works, in the v2 documentation I tested to see if it would work but I didn't have a good result, the layout works very well for large file extensions, but in my case mentioned it would be for files small ones, such as components, using the same layout method, but instead of setting directly as in the it.body example which changes the entire body to the layout value, add the value of the component in the example below to the already existing code, or I I don't understand the layout and it already does this? If I'm sorry for saying that qwq

image

nebrelbug commented 3 months ago

@drylian I'm not completely sure what you're saying, but if you want to pass child content to multiple includes/layouts in just one template, that's not currently supported. Maybe there's some way to make it work though!