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

Feature request: optional blocks #30

Open
BrianHicks opened this issue Aug 27, 2019 · 0 comments
Open

Feature request: optional blocks #30

BrianHicks opened this issue Aug 27, 2019 · 0 comments

Comments

@BrianHicks
Copy link

Problem

I am writing templates to render instructions for our students. Right now it's done using naive string replacement, and so I'm using elm-markup to make something a little more robust. A sample template might start like Good job, {{NAME}}!, which I've translated to Good job, []{studentName}!.

One reason I'm doing this is because we want to give our curriculum department the ability to insert links to more detailed lessons in the middle of the instruction text. I've got that working ([See an example]{lesson|id=2}.)

While I was doing this, I wanted to add a way to optionally set an icon in the button link. That doesn't look like it's possible right now! It seems like there are no optional fields in records. I'd like to be able to do that for some other things I have planned, so I thought I'd open an issue and ask.

Suggestion

I would like something like:

optionalField : String -> Block value -> Record (Maybe value -> result) -> Record result

which, for annotation "x" identity |> optionalField "field" int, would mean:

input output
[]{x|field=1} Success (Just 1)
[]{x} Success Nothing
[]{x|field=foo} Failure …

verify would only run if the value is present, and would cause failure normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant