-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a custom div instead of duplicating the block #10
Comments
The reason for the AST transform is that it has zero runtime cost, unlike a component. Is there a reason that magically duplicated block is a problem for you? |
Sometimes the block can contain bigger templates than a single component, which in a way will increase the template size. And although this can be avoided by creating a component and using it inside the block, I can see a lot of people just putting a lot of presentation logic inside there. I guess it is a micro optimisation - template size vs runtime cost. It was just an idea that I wanted to share. |
It makes sense. There is a middle ground thing we can do it would improve things in the most common use case. The block is duplicated because of the |
That is a nice idea. I can create a PR towards the end of the week. |
Now when I think about it why would you use |
None really, other than consistency. At the end, using something that starts with |
FWIW, this not zero cost, it is double the bytes of whatever the block. I think the modern suggestion would be to make a template only component that does: {{#if @renderInPlace}}
{{yield}}
{{else}}
{{#in-element @destinationElement insertBefore=null}}
{{yield}}
{{/in-element}}
{{/if}} |
The idea is to have a component instead of an AST transform. This way there will be no need to have the same block twice.
Something in the lines of
or maybe even something like. The bottom code works although I am not sure if it will cause any problems.
The text was updated successfully, but these errors were encountered: