|
1 | | -<li id="qna-question-{{ question.id }}" class="qna-question-list__item"> |
2 | | - <article class="qna-question" aria-labelledby="qna-question-{{ question.id }}-text"> |
| 1 | +{% set item_attributes = attrs() |
| 2 | + .set('id', "qna-question-#{question.id}") |
| 3 | + .addClass('qna-question-list__item') |
| 4 | + .mergeWith(item_attributes|default) |
| 5 | +%} |
| 6 | +{% set question_attributes = attrs() |
| 7 | + .addClass('qna-question') |
| 8 | + .addClass('qna-question--answered', question.answered) |
| 9 | + .addClass('qna-question--own', question.isOwn) |
| 10 | + .set('aria-labelledby', "qna-question-#{question.id}-text") |
| 11 | + .mergeWith(question_attributes|default) |
| 12 | +%} |
| 13 | + |
| 14 | +<li{{ item_attributes }}> |
| 15 | + <article{{ question_attributes }}> |
3 | 16 | <p id="qna-question-{{ question.id }}-text" class="qna-question__text">{{ question.question }}</p> |
4 | 17 | <p class="qna-question__votes"> |
5 | 18 | {{ 'qna.question.vote_count'|trans([question.voteCount], 'contao_default') }} |
|
10 | 23 | {% endif %} |
11 | 24 |
|
12 | 25 | {% if answer_url|default(null) %} |
13 | | - <form class="qna-answer-form" action="{{ answer_url }}" method="post"> |
| 26 | + <form{{ attrs().addClass('qna-answer-form').set('action', answer_url).set('method', 'post') }}> |
14 | 27 | <input type="hidden" name="REQUEST_TOKEN" value="{{ request_token }}"> |
15 | | - <button id="qna-question-{{ question.id }}-answer" class="qna-button" type="submit" aria-describedby="qna-question-{{ question.id }}-text"> |
| 28 | + <button{{ attrs() |
| 29 | + .set('id', "qna-question-#{question.id}-answer") |
| 30 | + .addClass('qna-button') |
| 31 | + .set('type', 'submit') |
| 32 | + .set('aria-describedby', "qna-question-#{question.id}-text") |
| 33 | + }}> |
16 | 34 | {{ (question.answered ? 'qna.question.mark_unanswered' : 'qna.question.mark_answered')|trans({}, 'contao_default') }} |
17 | 35 | </button> |
18 | 36 | </form> |
19 | 37 | {% endif %} |
20 | 38 |
|
21 | 39 | {% if show_vote_button and not question.answered %} |
22 | | - <form class="qna-vote-form" action="{{ vote_url }}" method="post"> |
| 40 | + <form{{ attrs().addClass('qna-vote-form').set('action', vote_url).set('method', 'post') }}> |
23 | 41 | <input type="hidden" name="REQUEST_TOKEN" value="{{ request_token }}"> |
24 | | - <button |
25 | | - id="qna-question-{{ question.id }}-vote" |
26 | | - class="qna-button qna-vote-button{{ question.hasVoted ? ' qna-vote-button--selected' : '' }}" |
27 | | - type="submit" |
28 | | - aria-label="{{ (question.hasVoted ? 'qna.vote.selected_label' : 'qna.vote.label')|trans([question.question], 'contao_default') }}" |
29 | | - aria-pressed="{{ question.hasVoted ? 'true' : 'false' }}" |
30 | | - > |
| 42 | + <button{{ attrs() |
| 43 | + .set('id', "qna-question-#{question.id}-vote") |
| 44 | + .addClass(['qna-button', 'qna-vote-button']) |
| 45 | + .addClass('qna-vote-button--selected', question.hasVoted) |
| 46 | + .set('type', 'submit') |
| 47 | + .set('aria-label', (question.hasVoted ? 'qna.vote.selected_label' : 'qna.vote.label')|trans([question.question], 'contao_default')) |
| 48 | + .set('aria-pressed', question.hasVoted ? 'true' : 'false') |
| 49 | + }}> |
31 | 50 | {{ (question.hasVoted ? 'qna.vote.selected' : 'qna.vote.submit')|trans({}, 'contao_default') }} |
32 | 51 | </button> |
33 | 52 | </form> |
|
0 commit comments