You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But it's not currently possible to embed it same way with n:embed, but latte plugin in phpstorm recognize this as valid latte attribute?
It's up to you to make a strong case to convince the project's developers of the merits of this feature
I think that n: macros are strong feature in latte, that no other php/js template engine has. With the strong adoption of TailwindCSS or AlpineJS, the n:define and n:embed would be strong feature for reusable UI components. You could define UI component with n:define and then reuse it in the code with n:embed. So there wouldn't be a lot of duplicated code with the same component. That's currently not possible to do in a good way with the other php/js template engines, and seems latte is one step away from this feature.
To embed that defined component, it's currently only possible to do with {embed}, like this
But this has it's limitations, let's say you want to extend the component with new classes, or attributes. You would have to define it as params in the n:define and add it as variables in the brackets {}, which could cause problems with tailwindcss detecting the classes, or other purgecss plugins.
Something like this would be much better and easier to use
For a big projects that reuse a lot of UI components this would be a massive improvement. In @newlogic-digital we noticed this ourselfs. We have a lot of UI components and templates in our projects, and if something like n:embed was possible it would result into reducing a lot of duplicate code. We try to use embed and include when possible, but it's not always ideal.
Currently it's possible to define component with
n:define
, like thisBut it's not currently possible to embed it same way with
n:embed
, but latte plugin in phpstorm recognize this as valid latte attribute?I think that
n:
macros are strong feature in latte, that no other php/js template engine has. With the strong adoption of TailwindCSS or AlpineJS, then:define
andn:embed
would be strong feature for reusable UI components. You could define UI component withn:define
and then reuse it in the code withn:embed
. So there wouldn't be a lot of duplicated code with the same component. That's currently not possible to do in a good way with the other php/js template engines, and seems latte is one step away from this feature.To embed that defined component, it's currently only possible to do with
{embed}
, like thisBut this has it's limitations, let's say you want to extend the component with new classes, or attributes. You would have to define it as params in the
n:define
and add it as variables in the brackets{}
, which could cause problems with tailwindcss detecting the classes, or otherpurgecss
plugins.Something like this would be much better and easier to use
Which would output to
Even better would be if
define
had something like js has<slot></slot>
, so you wouldn't need to writeblock
inembed
everytime.For a big projects that reuse a lot of UI components this would be a massive improvement. In @newlogic-digital we noticed this ourselfs. We have a lot of UI components and templates in our projects, and if something like
n:embed
was possible it would result into reducing a lot of duplicate code. We try to useembed
andinclude
when possible, but it's not always ideal.We would love to support nette and latte directly! I've sended a few emails and contacted you on twitter with no response 😞
The text was updated successfully, but these errors were encountered: