Questions: Table not being shown; Accounts not selecting from CY information

Hi there

Just recently started using Liquid/Markup, and have 3 questions from the same coding:

    • When creating tables, sometimes it works, sometimes it doesn’t show as a table correctly (see below)
    • This is not picking up the actual values in the accounts, instead displaying £0.00
    • Not 100% whether the $1 is being updated correctly.

Coding:

{% stripnewlines %}
|--------------70%----------
|---------30%----------:+
{% newline %}
|Select account numbers
|{% input custom.payroll.gross as:account_collection range:1__9 accounts_var:payroll_gross %}
{% newline %}
{% for account in payroll_gross %}
|{{ account.name }}
|{{ $1+ account.value | currency }}
{% newline %}
{% endfor %}


{{ %1 }}
{% endstripnewlines %}

This shows the following output:

|————–70%———-|———30%———-:+
|Select account numbers|
|Sales|0.00
|Use of home as office|0.00
|Insurance|0.00
|Salary - Directors|0.00
|Director’s NI|0.00
|Wages|0.00
|Travelling|0.00
|CIPR membership|0.00
|R&R|0.00
|Sundry|0.00
|Accountancy|0.00

Hi @ThomasB,

I have some suggestions for you.

  1. I think it’s because the newline tag is not properly used; I always add this tag to every new line that presents itself (see my code below)
  2. That’s because you write down {{ $1+ account.value | currency }} but if you are using a register, you’ll need logic tags (so {% %}). This is the code you’re looking for:
{% =$1+ account.value %} 

Mind the equation mark = as well; if you don’t do that, the value of the account will be saved in the register but it won’t be displayed for each account.

  1. It’s not updated because you use {{ %1 }} instead of {{ $1 }}

I’ve updated your code with this:

{% stripnewlines %}
|--------------70%----------
|---------30%----------:+
{% newline %}
|Select account numbers
|{% input custom.payroll.gross as:account_collection range:1__9 accounts_var:payroll_gross %}
{% for account in payroll_gross %}
{% newline %}
|{{ account.name }}
| {% =$1+ account.value %}
{% endfor %}

{% newline %}
|
| **{{ $1 }}**
{% endstripnewlines %}

Let me know if any of this would be unclear to you; glad to help you forward, and already some nice coding you did!

Hi Sven

Thank you for the reply.

I’m struggling to identify the requirements for a table, and comparing stripnewlines with the same code, excluding stripnewlines:

Trial 1

{% stripnewlines %}
|--------------70%----------
|---------30%----------:+
{% newline %}
|Select account numbers
|{% input custom.payroll.gross as:account_collection range:1__9 accounts_var:payroll_gross %}

{% for account in payroll_gross %}
{% newline %}
|{{ account.name }}
|{% =$1+ account.value | currency %}

{% endfor %}


{{ $1 }}
{% endstripnewlines %}


Trial 2

{% assign $1 = 0 %}
|--------------70%----------|---------30%----------:+
|Select account numbers|{% input custom.payroll.gross as:account_collection range:1__9 accounts_var:payroll_gross %}{% for account in payroll_gross %}
|{{ account.name }}|{% =$1+ account.value | currency %}{% endfor %}

{{ $1 }}

From what I can see, the first section and the second section are the same, just with/without stripnewlines formatting.

But running them provides Test 1 in table format, and Test 2 in non-table format.

I’m happy with most of the coding and logic I’ve seen so far, but for some reason I’m tripping up when I try to sort out tables.

@ThomasB,

Perhaps this post will clear it up for you a little:

Don’t feel bad, as I had issues in the beginning as well with this: when I started building templates, there was no such thing and everything had to be structured the way you did for Test 2 (I’m not sure on why you say it doesn’t has a table format? It does, and is perfectly structured like I would’ve done without stripnewlines).

I personally prefer stripnewlines and newlines now, and I continue to work like this with my one rule: a newline is added as soon as a new row is needed.
So, if you create a table within stripnewlines, you first line of code is not new - you just start with it. If you think of it this way, you should be good to go.
(of course, you’re not obligated to use this - but just look at our old templates, and you’ll see it can become quite complicated to read the code).

Hope this helps you out a bit?