mirror of
https://github.com/pmoreno-rodriguez/grav-theme-future2021.git
synced 2025-06-07 20:08:54 +00:00
19 lines
No EOL
798 B
Twig
19 lines
No EOL
798 B
Twig
{%- macro render_field(form, fields, scope) %}
|
|
{%- import _self as self %}
|
|
{%- for index, field in fields %}
|
|
{%- set input = attribute(field, "input@") %}
|
|
{%- if input is null or input == true %}
|
|
{%- set value = form.value(scope ~ (field.name ?? index)) %}
|
|
{{- scope ~ (field.name ?? index) }}: {{ string(value is iterable ? value|json_encode : value|escape('yaml')) ~ "\r\n" }}
|
|
{%- else %}
|
|
{%- if field.fields %}
|
|
{%- set new_scope = field.nest_id ? scope ~ field.name ~ '.' : scope -%}
|
|
{{- self.render_field(form, field.fields, new_scope) }}
|
|
{%- endif %}
|
|
{%- endif %}
|
|
{%- endfor %}
|
|
{%- endmacro %}
|
|
{%- import _self as macro %}
|
|
{%- autoescape false %}
|
|
{{- macro.render_field(form, form.fields, '') ~ "\r\n" }}
|
|
{%- endautoescape %} |