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

Templating wish list #26

Open
CITguy opened this issue Feb 8, 2024 · 2 comments
Open

Templating wish list #26

CITguy opened this issue Feb 8, 2024 · 2 comments

Comments

@CITguy
Copy link

CITguy commented Feb 8, 2024

I'd like to use this issue to keep track of stuff I wish I could do with the templating logic.

Ideally, I wish I could use an established templating language like EJS or doT.js.

@CITguy
Copy link
Author

CITguy commented Feb 8, 2024

One thing I can't do is a "default" fallback for when a property has multiple values.

Currently, I have to negate all other values to get a "default" / fallback condition.

{{?prop=a}}content A
{{?prop=b}}content B
{{?prop=c}}content C
..
{{!prop=a&prop=b&prop=c&prop=...}}fallback content

I wish I could use more of a "switch/case"-like syntax...

{{?prop=a}}content A
{{?prop=b}}content B
{{?prop=c}}content C
...
{{?prop=*}}fallback content

@CITguy
Copy link
Author

CITguy commented Feb 8, 2024

Conditional blocks

Say I have a Button component with the following setup...

Button
  - iconOnly:boolean(false)
  - label:string('button')
  - iconLeft:instanceSwap
  - iconRight:instanceSwap

the following table illustrates which props apply for different values of iconOnly

  iconOnly == true iconOnly == false
label
iconLeft
iconRight

Current

<my-button
  {{?property.iconRight}}iconright="{{property.iconRight}}"
  {{?property.iconOnly=true|property.iconLeft}}iconleft="{{property.iconLeft}}"
{{?property.iconOnly=true}}></my-button>
{{?property.iconOnly=false}}>
{{?property.iconOnly=false}}  {{property.label}}
{{?property.iconOnly=false}}</my-button>

Ideal

Using EJS syntax for block conditionals...

<% if (property.iconOnly == true) { %>
<my-button
  iconleft="{{property.iconLeft}}"
></my-button>
<% } else { %>
<my-button
  {{?property.iconRight}}iconright="{{property.iconRight}}"
  {{?property.iconLeft}}iconleft="{{property.iconLeft}}"
>
  {{property.label}}
</my-button>
<% } %>

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