-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Cannot access templateVars.options in templates #5730
Comments
Actually, I am wondering why do we have An idea @clarkdo? |
@Atinux I'm not sure the initial situation, but I suppose that user may need sth like @hecktarzuli Thanks for the reporting, I'll propose a fix. |
For more context @Atinux , in our case, our system generates 6 websites, and so we have an advanced config system and need config data in our plugins so we can build them using the right settings. |
@hecktarzuli As @pi0 pointed, merge |
Sounds good to me. That's probably the safest course of action. If it's going to be undocumented, then what's the point of the merge if nobody knows about it? |
@hecktarzuli There are some other libraries/modules are using |
@hecktarzuli Modules that really need can leverage it. Indeed we can document it in the future. Not documenting for now is more because to not encourage using it over explicit templateFile.options. And also due the fact that some internal config refactors may impact usage. |
Version
v2.7.0
Reproduction link
https://codesandbox.io/s/946pw7j9k4
Steps to reproduce
a) create a module that injects a plugin
b) have plugin use lodash syntax to fill in vars from templateVars
c) notice that even though templateVars.options exists, it's { } in the written template
The problems seems to be with https://github.com/nuxt/nuxt.js/blob/dev/packages/builder/src/builder.js#L515 which merges options with the template, even if options isn't passed.
What is expected ?
My assumption is that anything you see in templateVars should be accessible in a template!
What is actually happening?
options prop is being reset
Additional comments?
a) could maybe see if options is being passed to the template, then let it override it (which still is kind of crummy)
b) could move either options or templateVars.options into a new prop in templateVars so it's always accessible.
The text was updated successfully, but these errors were encountered: