CASE: have one table header different alligned from the sub-headers

Here’s an example of what you can create within a template, where the main header is divided in 2 columns and centered, while the sub-headers and the columns beneath it, are differently alligned:

This is the code behind it:

{% assign regular_costs = #61 %}

{% stripnewlines %}
{% for acc in regular_costs %}
{% if forloop.first %}
| Account info
| Account values
{% newline %}
|:----60%----:
|:----40%----:+
{% newline %}
{% newline %}
| Acc. Nbr
| Acc. Name
| Mapped number
| Opening Value
|
| End Value
{% newline %}
|----10%----
|----30%----
|----20%----
|----15%----
|----10%----
|----15%----+
{% endif %}
{% newline %}
| {{ acc.number }}
| {{ acc.name }}
| {{ acc.original_number }}
| {{ acc.opening_value | currency }}
|
| {{ acc.value | currency }}
{% endfor %}
{% endstripnewlines %}

As you can see, is that there are 2 newline tags. This is needed to divide the two different tabled from each other; if there would be only one newline, Liquid will read the whole code as one table instead of 2 different tables.
So be sure to use 2 newline tags for this!

1 Like

Using the logic that the two newline tags are used to divide the two tables from each other, shouldn’t the following code work? I am getting a broken table underneath the first header.

Note that I have removed the if statement and forloop as it doesn’t apply to this particular table I am trying to create. If the if statement is needed, is there a way to create the table within table without the forloop?

{% stripnewlines %}
| JJJ
| JJJ
| JJJ
| JJJ
{% newline %}
|-----26%-----
|:----36%----:
|------2%-----
|:----36%----:+
{% newline %}
{% newline %}
| a
| a
| a
| a
| a
| a
| a
| a
{% newline %}
|-----26%-----
|:----12%----:
|:----12%----:
|:----12%----:
|------2%-----
|:----12%----:
|:----12%----:
|:----12%----:+
{% newline %}
| x
| x
| x
| x
| x
| x
| x
| x
{% endstripnewlines %}

Hey @Spencer.Posner,

Your posted code works fine if I use it:

Is this still an issue at your part?

No it works now, thank you.

The issue was that I had indented the pipes for ease of reading my code, but once I removed all the indents, it worked well.

Thanks for the feedback @Spencer.Posner! :ok_hand: