-
-
Notifications
You must be signed in to change notification settings - Fork 31
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 merge operator for variables #70
Comments
|
I'm thinking of a custom syntax to do that, for example I've tried to add this: - "<<:[[entity]]": null
view_layout:
grid-area: main
const rxp3 = new RegExp(`"<<:\\[\\[${key}\\]\\]":null`, 'gm');
jsonConfig = jsonConfig.replace(rxp3, valueString.slice(1, -1)); This basically works, just as a quick hack. Of course it would be nice expanding on this syntax. For example, I would also like to not add anything when the variable isn't defined. What do you think about adding a special syntax for this? If you're interested I could create a PR for this. |
I would love this too. Here's my example. Template:
Card config:
|
@droans |
Is your feature request related to a problem? Please describe.
I would like to define a map of properties to customize how a card is shown. In my example I use the layout card to customize layouting, but I want to be able to dynamically set which cards are rendered.
Apparently the
<<:
operator right now is processed before the variables are processed. So in my example below, yaml processes this:instead of this:
Describe the solution you'd like
Add support for the
<<:
operator for variables. This way you can specify defaults for a card, and extend the defaults with an arbitrary object.Describe alternatives you've considered
I would have to specify each and every attribute as a variable. As I want to be able to use any card type, I would have to go over all properties I want and specify them as variables.
Additional context
Template
Usage
Edit: If the yaml processing cannot be deferred, maybe a special syntax for variables can be added,
<<: [[entity]]
. ThedeepReplace
function can then spread the object onto the config.The text was updated successfully, but these errors were encountered: