-
| Hey! Is it possible to use variables in switch-cases? I want to implement something in a similar way like this: const text = 'I’m {age:number} years old{hasRegion|{true: from {region}, false:}}.'; const str = LLL(test, { age: 10, hasRegion: true, region: 'Asia' });Expected output: const str = LLL(test, { age: 10, hasRegion: false });Expected output: The output I get at the moment is Is that possible at all? |
Beta Was this translation helpful? Give feedback.
Answered by ivanhofer Aug 9, 2023
Replies: 1 comment 1 reply
-
| Hi, thanks for your kind words :) No, this is currently not possible. It is not the prettiest code, but you could do it like this: const text = 'I’m {age:number} years old {appendix:string}' const textAppendix = 'from {region}' const region = 'Asia' const str = LLL(text, { age: 11, appendix: region ? LLL(textAppendix, { region }) : '' }).trim()Do you really use the raw |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by jnsprnw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Hi, thanks for your kind words :)
No, this is currently not possible.
It is not the prettiest code, but you could do it like this:
Do you really use the raw
LLLfunction with plain strings instead of theLLfunction with an dictionary object?