• 
      

    Add a template tag for generating a unique ID.

    Review Request #14547 — Created Aug. 3, 2025 and submitted — Latest diff uploaded

    Information

    Djblets
    release-5.x

    Reviewers

    We have many cases where we need a unique ID for the purposes of the
    aria-labelledby= or aria-describedby= attribute. In some cases, it's
    a bit burdensome to have to come up with an ID, as templates are
    sometimes generated dynamically based on iterating over other content.

    This introduces a {% unique_id %} template tag that takes in a prefix
    and outputs that prefix followed by an auto-incremented ID. It works
    much like Underscore.js/Lodash's _.uniqueId(). function.

    IDs are only unique if precautions are taken. It can't know how the ID
    will be used or what else may be on the page. However, it won't generate
    the same ID across different calls on the same template render.

    Unit tests passed.

    Made use of this in some in-progress code.

    Commits

    Files