rdmo icon indicating copy to clipboard operation
rdmo copied to clipboard

Add a simple_tag for views to render a list of values

Open MyPyDavid opened this issue 10 months ago • 1 comments

This tag should return a readable string from a list of Values in a View template. The default keyword arguments for this simple tag are separator sep = ',' and the second to last separator sep_last = ', and'. The name of the tag is currently render_custom_inline_list.

For example for a list of possible values (like in a optionset) A, B, C, D it should return:

A, B, C, and D A, B, and C A and B A

In the View for example:

<p> Im Projekt entstehen Daten
{% for dataset in datasets %}
    {% if forloop.last and not forloop.first %}und {% endif %}
    im Bereich <i>{{ dataset.value }}</i> durch
    {% get_set_values dataset 'project/dataset/creation_methods' as texts %}
    {% render_custom_inline_list values=texts sep=';' sep_last='und' %}
{% endfor %}
</p>

Co-authored-by: @jwindeck

Description

Related issue: #ISSUE_NUMBER

Motivation and Context

How has this been tested?

Screenshots (if appropriate)

Types of Changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Code style update (formatting, renaming)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] Documentation content changes
  • [ ] Other (please describe):

Checklist

  • [x] I have read the contributor guide.
  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [ ] I have added tests to cover my changes.
  • [ ] All new and existing tests passed.

MyPyDavid avatar Apr 05 '24 15:04 MyPyDavid

addresses https://github.com/rdmorganiser/rdmo/issues/964

Zack-83 avatar Apr 12 '24 10:04 Zack-83

thanks, looks much better with the separator_two

MyPyDavid avatar May 17 '24 14:05 MyPyDavid