File size: 3,167 Bytes
7d0c16f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0324409
7d0c16f
 
 
 
 
 
 
 
 
 
 
 
 
 
0324409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7d0c16f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{% macro metadata_block(metadata) -%}
  {% if metadata %}
  <div class="section">
    <h2>Metadatos</h2>
    <div class="card-grid">
      {% if metadata.script_type %}<div class="card"><strong>Tipo:</strong> {{ metadata.script_type }}</div>{% endif %}
      {% if metadata.suitescript_version %}<div class="card"><strong>SuiteScript:</strong> {{ metadata.suitescript_version }}</div>{% endif %}
      {% if metadata.language %}<div class="card"><strong>Lenguaje:</strong> {{ metadata.language }}</div>{% endif %}
      {% if metadata.module_type %}<div class="card"><strong>Módulo:</strong> {{ metadata.module_type }}</div>{% endif %}
    </div>
    {% if metadata.description %}<p>{{ metadata.description }}</p>{% endif %}
    {% if metadata.dependencies %}
      <p class="muted">Dependencias:
        {% for dep in metadata.dependencies %}
          <span class="pill">{{ dep }}</span>
        {% endfor %}
      </p>
    {% endif %}
  </div>
  {% endif %}
{%- endmacro %}

{% macro summary_block(text) -%}
  {% if text %}
    <div class="section">
      <h2>Resumen Ejecutivo</h2>
      <div class="summary-box">{{ text }}</div>
    </div>
  {% endif %}
{%- endmacro %}

{% macro list_block(title, items) -%}
  {% if items %}
    <div class="section">
      <h2>{{ title }}</h2>
      <ul>
        {% for item in items %}
          <li>
            {% if item is mapping %}
              {% for key, value in item.items() %}
                <strong>{{ key|replace('_',' ')|title }}:</strong> {{ value }}{% if not loop.last %}; {% endif %}
              {% endfor %}
            {% else %}
              {{ item }}
            {% endif %}
          </li>
        {% endfor %}
      </ul>
    </div>
  {% endif %}
{%- endmacro %}

{# --------- AQUÍ ESTÁ EL CAMBIO IMPORTANTE --------- #}
{% macro table_block(title, rows, columns) -%}
  {% if rows %}
    <div class="section">
      <h2>{{ title }}</h2>
      <table>
        <thead>
          <tr>
            {% for column in columns %}
              <th>{{ column.title }}</th>
            {% endfor %}
          </tr>
        </thead>
        <tbody>
          {% for row in rows %}
            {# Si row es un dict: comportamiento normal #}
            {% if row is mapping %}
              <tr>
                {% for column in columns %}
                  {% set value = row.get(column.field) %}
                  {% if value is sequence and value is not string %}
                    <td>{{ value|join(", ") }}</td>
                  {% else %}
                    <td>{{ value or "" }}</td>
                  {% endif %}
                {% endfor %}
              </tr>
            {% else %}
              {# Fallback: fila no estructurada (string, número, etc.) #}
              <tr>
                <td colspan="{{ columns|length }}">
                  {{ row }}
                </td>
              </tr>
            {% endif %}
          {% endfor %}
        </tbody>
      </table>
    </div>
  {% endif %}
{%- endmacro %}

{% macro logic_block(title, text) -%}
  {% if text %}
    <div class="section">
      <h2>{{ title }}</h2>
      <p>{{ text }}</p>
    </div>
  {% endif %}
{%- endmacro %}