Extend @R_str to allow escaped strings
See original GitHub issueI just stumbled upon an issue while using the macro @R_str in combination with variables. As macros execute the input in a different namespace, it is not possible to dynamically access e.g. array fields in a loop.
Problematic behavior:
@R_str "myArray[item.id]" led to this error: item not defined
Workaround / proposed fix:
I added another macro with an escaped string, which solved the problem for me:
macro R_str_esc(s)
:(Symbol($(esc(s))))
end
Issue Analytics
- State:
- Created 2 years ago
- Comments:10
Top Results From Across the Web
Escaping strings - ETL
Escaping a string means to reduce ambiguity in quotes (and other characters) used in that string. For instance, when you're defining a string,...
Read more >why using javascript escape character of quotation in string ...
The trick is that the string is escaped and upon assignment immediately unescaped (by executing a JavaScript expression) on the fly, i.e. .value ......
Read more >How to Escape Special Characters of a Python String ... - Finxter
Rate this post. The backslash escape character '\' is a special Python string character that is usually followed by an alphabetic character.
Read more >String resources | Android Developers
When a string contains characters that have special usage in XML, you must escape the characters according to the standard XML/HTML escaping ......
Read more >Escape Sequences - Salesforce Help
You can use the backslash character (\) to escape characters in column names and string values in a predicate expression. You can use...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Escaping for R_str is not a good idea. The reason is that Vue supports javascript expressions to be evaluated for its fields. Imagine you would have an array of tooltips
tips = ["Hello", "World"]and you wanted to link the first array element to your tooltip. In html code this would readWith StippleUI this translates to
This would not be possible to write with escaped syntax. Also note the zero-based indexing in javascript.
For your use case I’d rather go for converting it to
Symbolexplicitly:Thank you, that works as intended without the macro!