-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Motivation
Currently, when defining a selector with param=room in JSON:
{
"notification": {
"lessonBody(param=room)": {
"empty": "$time",
"other": "$time • room $room"
}
}
}Slang generates two separate methods (empty(...) and other(...)). The developer must manually decide which one to call in code.
It would be useful to have an inline selector feature, similar to ICU select, where the generator produces one method (e.g. lessonBody(...)) and automatically chooses the correct branch based on the parameter value.
Developer Experience
Proposed syntax:
{
"notification": {
"lessonBody(select, param=room)": {
"empty": "$time",
"other": "$time • room $room"
}
}
}Expected generated API:
String lessonBody({required DateTime time, required String room});Usage:
final body = t.notification.lessonBody(time: lesson.start, room: lesson.room);If room is empty → returns $time.
If room is non‑empty → returns $time • room $room.
Benefits
- Cleaner developer experience.
- Less duplication in generated code.
- More intuitive for those familiar with ICU select.
- Consistent handling of string‑based conditions (empty/non‑empty, status values, gender, etc.).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request