How to insert "tab" between two variables with Capture?

Hi,

We have a table where in one place we have a fori loop. The information in this fori will be used in a result and “moved” to another summarizing template (where we will have text from several modules).

I almost have what I want, but as you can see in the picture below, depending on how long item.company_name_paid_by is, the item.amount_paid is in different places. Is there someway to get these number to align?

{% assign test_SE_array = “” %}
{% fori item in custom.booked_company_paid_by %}
{% capture holder %}{% t “fyll_i_bolagsnamn” %}{% endcapture %}
| {% input item.company_name_paid_by default:item.default_text placeholder:holder %}
{% rollforward item.company_name_paid_by item.default_text %}
| {%=$0+input item.amount_paid as:currency precision:0 placeholder:0 %}
{% rollforward nil item.amount_paid %}
{% newline %}
{% if forloop.first == true %}
{% capture x %}Bolaget har i inkomstdeklarationen för beskattningsåret {{ fy }} mottagit koncernbidrag från följande bolag.{% endcapture %}
{% capture y %}- {{ item.company_name_paid_by }}    {{ item.amount_paid }} {% endcapture %}
{% assign test_SE_array = test_SE_array | append:x | append:"

" %}
{% assign test_SE_array = test_SE_array | append:y | append:"
" %}
{% elsif forloop.last == true %}
{% capture y %}- {{ item.company_name_paid_by }}    {{ item.amount_paid }} {% endcapture %}
{% assign test_SE_array = test_SE_array | append:"
" | append:“Beloppet/beloppen har redovisats under kod 3.20 i Bolagets inkomstdeklaration.” %}
{% else %}
{% capture y %}- {{ item.company_name_paid_by }}    {{ item.amount_paid }} {% endcapture %}
{% assign test_SE_array = test_SE_array | append:y | append:"
" %}
{% endif %}
{% endfori %}

Kind regards,
Anna

Hi Anna,

Thanks for your question. Unfortunately, there is not a way to add a “tab” functionality in a string however we can align the results in another way. The easiest is to use a table to control the alignment and to facilitate this we will need to split the data up into separate arrays and variables. I have added two variables to store the text used and created two arrays for the table data:

{% stripnewlines %}
{% comment %}Set-up arrays{% endcomment %}
{% assign test_SE_array = “” %}
{% assign test_SE_array_numbers = “” %}

{% comment %}assign text variables{% endcomment %}
{% assign text1 = “Bolaget har i inkomstdeklarationen för beskattningsåret {{ fy }} mottagit koncernbidrag från följande bolag.” %}
{% assign text2 = “Beloppet/beloppen har redovisats under kod 3.20 i Bolagets inkomstdeklaration.” %}

{% fori item in custom.booked_company_paid_by %}
{% capture holder %}{% t “fyll_i_bolagsnamn” %}{% endcapture %}
| {% input item.company_name_paid_by default:item.default_text placeholder:holder %}
{% rollforward item.company_name_paid_by item.default_text %}
| {%=$0+input item.amount_paid as:currency precision:0 placeholder:0 %}
{% rollforward nil item.amount_paid %}
{% newline %}

{% capture y %}-{{ item.company_name_paid_by }}{% endcapture %}
{% capture z %}{{ item.amount_paid }}{% endcapture %}

{% assign test_SE_array = test_SE_array | append:y | append:"|" %}
{% assign test_SE_array_numbers = test_SE_array_numbers | append:z | append:"|" %}

{% endfori %}
{% endstripnewlines %}

{% comment %}Generate results for summary template{% endcomment %}
{% result ‘text1’ text1 %}
{% result ‘text2’ text2 %}
{% result ‘test_SE_array’ test_SE_array %}
{% result ‘test_SE_array_numbers’ test_SE_array_numbers %}

In the end template where you want the data to be displayed you can use the following code (variables will need to be replaced with the results eg. period.reconciliations.HANDLE.results.text1):

{% comment %}To display result data{% endcomment %}
{% assign test_SE_array = test_SE_array | split:"|" %}
{% assign test_SE_array_numbers = test_SE_array_numbers | split:"|" %}

{% stripnewlines %}
{{ text1 }}
{% newline %}{% newline %}

{% for item in test_SE_array %}
{% if forloop.first == true %}
{% comment %}table format{% endcomment %}
{% newline %}
|—20%—
|—10%—
{% newline %}
|{{ item }}
|{{ test_SE_array_numbers.[forloop.index0] }}
{% else %}
{% newline %}
|{{ item }}
|{{ test_SE_array_numbers.[forloop.index0] }}
{% endif %}
{% endfor %}

{% comment %}last sentence{% endcomment %}
{% newline %}{% newline %}
{{ text2 }}
{% endstripnewlines %}

Hope that helps. Let us know if I can help clarify any points.