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

Data binding substitution failure on empty string #213

Closed
ZombieRaccoon opened this issue Jul 21, 2021 · 2 comments
Closed

Data binding substitution failure on empty string #213

ZombieRaccoon opened this issue Jul 21, 2021 · 2 comments
Labels
bug Something isn't working data binding

Comments

@ZombieRaccoon
Copy link

Hello,

I've recently encountered a phenomenon where binding an array of strings (ie. std::vector<Rml::String>) that may contain empty ones to a dropdown list using data-for results in the iterator name not being substituted in case of the empty ones.

The definition of the dropdown list looks something like this (the data variables are deliberately self-explanatory):

<select data-value="current_selection_index">
    <option data-for="array_of_strings" data-value="it_index">{{ it }}</option>
</select>

When rendered, the result is along the lines of the following:

<select value="0">
    <option selected value="0">lorem</option>
    <option value="1">{{ it }}</option>
    <option value="2">ipsum</option>
</select>

When the list contains only an empty string, then the following warnings are triggered:

Could not find variable name 'it' in data model.
Error in data expression at 4. Could not find data variable with name 'it'.
  " it "
       ^
Could not add data-text view to element: #text < selectvalue < select < body < #root#test.rml

Can you also confirm this issue? I've spent some time debugging the code, but I found the data binding logic quite complex overall without being in knowledge of its basic principles.

mikke89 added a commit that referenced this issue Jul 21, 2021
@mikke89 mikke89 added bug Something isn't working data binding labels Jul 21, 2021
@mikke89
Copy link
Owner

mikke89 commented Jul 21, 2021

Thanks! This was a bug indeed. Does not seem to have anything to do with the select/option/data-for in particular, just data text views not working properly when initialized with empty strings.

Let me know if the changes fix the issue for you.

@ZombieRaccoon
Copy link
Author

It works like a charm. Thanks for the prompt response!

@mikke89 mikke89 closed this as completed Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working data binding
Projects
None yet
Development

No branches or pull requests

2 participants