CASE: the render_configuration drop: how to manage the input, preview and export mode in liquid

Hi there :wave:,

Have you ever been confused about how to add logic in your code to show/hide certain information depending on which view mode you are in? Well, you are not alone!

A new drop has arrived in liquid to make things easier to understand. Please let me introduce you to render_configuration

This drop has 2 methods we can use to add logic in liquid: render_configuration.inputs? and render_configuration.documents?


  • render_configuration.inputs?

I) It is always true in input mode
II) It is always false in preview/export mode

This method can then be used in a similar way to the {% ic %} and {% nic %} tags but with an if statement instead. For example:

{% if render_configuration.inputs? == true %}
  {% input custom.draft.accounts? as:boolean %}Are these draft accounts?
{% elsif render_configuration.inputs? == false and custom.draft.accounts? == true %}
  DRAFT ACCOUNTS
{% endif %}

This will print the following in input mode:

image

and this in preview/export:

image


  • render_configuration.documents?

I) It is always false in input mode
II) It is always false in preview mode
III) It is false in export mode when the paperclip icon is disabled
IV) It is true in export mode when the paperclip icon is enabled

When I say the paperclip icon, I am talking about the below section in the export page (next to the template/account we want to export):
|84px;x42px;

We can use this method to hide attachments in preview mode and only show them in export when the paperclip icon has been ticked.

For example:

{% ifi render_configuration.documents? == true %}
  {% input custom.some.att as:file %}
{% endifi %}

The above will render as follows:

App.1 in this case is a clickable link that will take you to the attached document as an appendix in the pdf document that has been exported.

Bear in mind that attachments will always show in preview mode by default (if the above method is not used) and will always be hidden in export unless the paperclip icon is enabled.

Also, it is worth noting that the value of this methods cannot be changed. We can only print the values and create some logic around them.

I hope that helped!

Best,
Borja