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: Allow templating of field #41

Open
kongo09 opened this issue Jan 11, 2022 · 2 comments
Open

Feature Request: Allow templating of field #41

kongo09 opened this issue Jan 11, 2022 · 2 comments

Comments

@kongo09
Copy link

kongo09 commented Jan 11, 2022

The field attribute currently acts as a selector for the field of the feed to be displayed. It would be great if there was a possibility to apply templates to the field content.

Use case could be date formatting, where the field just contains and ISO date string but the frontend is supposed to display something nicer.

Extension: the field attribute could take more than one field, which then could be combined in a template.

Use case could be two data fields that are displayed in only one column. As a special case you do this already with the icons and the links.

@brylee123
Copy link

I would like to second this. Sometimes there's redundant information and I just want to filter it out.

@netsoft-ruidias
Copy link

use this fork: https://github.com/netsoft-ruidias/lovelace-list-card for templates

Then, you can use templates like this:

type: custom:list-card
entity: sensor.edenred_card
feed_attribute: transactions
row_limit: 25
columns:
  - title: Date
    field: date
    template: |
      [[[ return new Date(entry.date).toLocaleDateString('pt-PT'); ]]]
    style:
      - padding: 5px
      - color: var(--secondary-text-color);
  - title: Movement
    field: name
    template: |
      [[[ return entry.name.replace('Compra: ', ''); ]]]
    style:
      - padding: 5px
      - color: var(--secondary-text-color);
      - text-align: left;
      - white-space: nowrap;
      - overflow: hidden;
      - text-overflow: ellipsis;
  - title: Euros
    field: amount
    template: |
      [[[ return entry.amount.toFixed(2) + ' €'; ]]]
    style:
      - text-align: right
      - white-space: nowrap
      - padding: 5px

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

3 participants