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

How to implement an OR #136

Open
Samyssmile opened this issue Dec 13, 2022 · 1 comment
Open

How to implement an OR #136

Samyssmile opened this issue Dec 13, 2022 · 1 comment

Comments

@Samyssmile
Copy link

I want to achieve something like this pseudecode

if(a != null || b !=null)
peter
else{
jackson
}

Ist it possible with the newest version?

@agentgt
Copy link
Contributor

agentgt commented Dec 4, 2023

Ist it possible with the newest version?

OOB, No. The above might not even possible with Handlebars.

I recommend decorating the model (e.g. wrapping) or using JMustache Lambdas which are very powerful as they allow stack access.

I'll add code later but you could make a generic Condition builder lambda.

{{#a}}
{{#cond}}
{{#or}}
{{#b}}
{{#test}}

Finally do your or logic here.

{{/test}}
{{/b}}
{{/or}}
{{/cond}}
{{/a}}

But I imagine that might be a little too verbose for your liking so I think decorating is your best option.

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

2 participants