I need to reference field_role from a paragraph inside of a field--node template. The paragraph is an unlimited repeating field in the content type. The field template I am working with is the field in the content type which references the paragraph entity.
In the field template:
{% for item in items %}
<li>
<a href="#">{{ paragraph.field_role }}</a>
</li>
{% endfor %}
I've tried {{ content.field_role }} and {{ item.field_role }} as well.
Separately, I've also tried creating a preprocess hook for the field.
function theme_preprocess_field(&$variables, $hook) {
$paragraph = $variables['paragraph']->field_role->value;
$variables['var_role'] = $paragraph;
}
function theme_preprocess_entity(&$variables) {
if ($variables['entity_type'] == 'paragraphs_item') {
if(isset($variables['elements']['field_role']['#items'][0]['value'])){
$variables['var_role'] = $variables['elements']['field_role']['#items'][0]['value'];
}
}
}
(I know this would only pull the first item from the repeating field, but I'm just trying to get anything to render at this point.)
How can I achieve what I am trying to do?