Skip to content

Ternary syntax control string matcher #5

@nicholasudell

Description

@nicholasudell

It would simplify syntax and reduce small class clutter if we could include a ternary syntax conditional Control String Matcher.

Such a string would perhaps take the format {context:name?valueIfTrue:valueIfFalse} (from Example.cs)

{Person:Pronoun:Singular} bring{Person:Pronoun:IsAlwaysPlural?:s} you a gift

This would resolve to:

he brings you a gift

or

they bring you a gift

As long as the They pronoun returned true for IsAlwaysPlural

This would be set up something like this (in class Pronoun):

new ConditionalControlStringMatcher("IsAlwaysPlural", () => AlwaysPlural))

Some questions to consider:

  • Should the ControlStringMatcher definition allow modifying the result? In the above example, we could add additional, optional parameters to provide funcs that take the passed in ternary values ("" and "s") respectively, and then modify them some way based on internal logic.
  • Should we allow variables in the results? For example {Person:MiddleName:Exists?MiddleName:} which would only show a person's middle name if it existed.
  • Should we allow the context tree to go deeper? For example, allow something like {Person:MiddleName:Exists?MiddleName:Initial:} which would print the initial of the person's middle name if one exists, otherwise blank.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions