Hi,
When using the template below, the conditional text shows up in Silverfin, but disappears
when exporting to PDF. The intention was to have the text show by default, but allow disabling it.
Using the unless, it does seem to work.
With friendly regards,
Takis
{% ic %}
Show it {% input custom.ic.show_it as:boolean default:true assign:show_it %}
{% endic %}
DEBUG
show_it: {{ show_it }} (this shows up as true in Silverfin, but is empty in the PDF export)
custom.ic.show_it: {{ custom.ic.show_it }}
END
{% if show_it == true %}
Some text to show by default. This text appears when viewing the document in Silverfin, but disappears
when exporting to PDF.
{% endif %}
{% ic %}
Hide it {% input custom.ic.test_hide_it as:boolean %}
{% endic %}
{% unless custom.ic.test_hide_it == true %}
Same here. Some text to show by default. This text appears when viewing the document in Silverfin, but disappears
when exporting to PDF.
{% endunless %}
Hi,
I managed to get it working using this code:
{% assign default_show_text = true %}
{% ic %}
{% input custom.ic.show_text as:boolean default:default_show_text %}
{% endic %}
{% if custom.ic.show_text != nil %}
{% assign show_text = custom.ic.show_text %}
{% else %}
{% assign show_text = default_show_text %}
{% endif %}
{% if show_text %}
Some text to show by default.
{% endif %}
But it is quite a lot of code for just setting a checkbox to true by default… Is there a simpler way to get the same result?
With friendly regards,
Takis
Hi @Panagiotis_Issaris
Your initial issue was caused by the variable show_it
only existing in input-mode, since it was created inside ic-tags.
If I understand your use-case, I think the following code covers it and is indeed shorter:
{% assign show_text = custom.ic.show_text | default:true %}
{% ic %}
{% input custom.ic.show_text as:boolean default:true %}
{% endic %}
{% if show_text == true %}
Some text to show by default
{% endif %}
- Create a variable that catches whether to show the text, the variable should have the same default applied as the input itself
- Create the input in ic-tags with default
- Check against the variable created outside the ic-tags
Hope that helps!
Kind regards,
Romy
Hi @Romy_Vermeeren ,
Thanks for your helpful reply!
With friendly regards,
Takis