Skip to content

Possible to get parameters of a part in Twig mode? #893

Answered by samvtran
Kampi asked this question in Q&A
Discussion options

You must be logged in to vote

For arbitrary array access, using Twig filters like {{element.part.parameters|first.name}} for the first element or {{element.part.parameters|slice(0, -1)[3].name}} for arbitrary indexes should work (full list of allowed filters). They convert the parameters PersistentCollection to an array which you can use indexes with.

My homelab inventory has lots of unrelated parts, so I can't rely on parameter indexes. Instead, I put a few parameters I actually care about in a Label group so they fit on small 25mm tall labels. An example of a table that CKEditor and the label generator seem happy with:

<table>
    <tbody>
        <tr style="display:none">
            <td>
                {% for param 

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Kampi
Comment options

@samvtran
Comment options

Answer selected by Kampi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants