Skip to content
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

allow referencing previous c-vars when resolving #204

Closed
wants to merge 4 commits into from

Conversation

snopoke
Copy link

@snopoke snopoke commented Oct 16, 2024

This allows you to split up complex logic in cvars into multiple steps and avoid repeating logic.

Here's an example where the 2nd var references the value of the 1st var.

<c-vars
    :slot_is_empty="{{ slot|length|yesno:'false,true' }}"
    :make_square="{{ square|default_if_none:slot_is_empty }}" 
>/

@snopoke snopoke closed this Oct 16, 2024
@snopoke snopoke reopened this Oct 16, 2024
@wrabit
Copy link
Owner

wrabit commented Oct 16, 2024

@snopoke I was initially skeptical about allowing this because of the potential additional load this could introduce. For example, some component's I create have ~10 cvars, this component may be placed on the page 10 - 20 times, so that equates to around 100 / 200 additional instances of manipulating context vs the current state. But, after performance tests, I am seeing this change brings a render speed increase of ~30% (!). So please bear with me whilst I do some head scratching and looking into just why that could be and ensuring the benchmarks are up to scratch.

@snopoke
Copy link
Author

snopoke commented Oct 17, 2024

@snopoke I was initially skeptical about allowing this because of the potential additional load this could introduce. For example, some component's I create have ~10 cvars, this component may be placed on the page 10 - 20 times, so that equates to around 100 / 200 additional instances of manipulating context vs the current state. But, after performance tests, I am seeing this change brings a render speed increase of ~30% (!). So please bear with me whilst I do some head scratching and looking into just why that could be and ensuring the benchmarks are up to scratch.

Thanks for the note. 30% increase is fairly significant so definitely worth looking into. Let me know if I can assist.

This change isn't essential since there are other ways to accomplish it, it's mostly for convenience. If we don't end up merging this I think it would be useful to add a note to the docs to make it clearer that this doesn't work.

@snopoke snopoke closed this Nov 4, 2024
@snopoke snopoke deleted the patch-1 branch November 4, 2024 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants