Skip to content

@if(someOption){ value => .... } else { .... }  #166

@domdorn

Description

@domdorn

Today I tried to make use of a scala.Option in my twirl template but found it rather hard / unelegant to use it in a nice way.

what I had to do was

@if(myOption.isDefined) { 
 some code @myOption.get
} else {
 some alternative code
}

What I wanted was something like a map with an else block, basically this kind of code

@if(myOption) { value => 
 code when my value is @value
} else {
 code when my value is not present
}

Is there something like this already? If not, how would I get started in providing a PR?
Is it a good idea to enhance the "if" with this or should I focus on implementing a new thing like @ifdefined(myOption) { value => ... } else { .. } ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions