twig split function
Hi,
in the notes of a product I have different lines, each line begins with a dash (‘-’). In my template for the invoice I would like to generate in the product table different list items from the notes by using the split function in twig as follows:
<td>
<p>{{ item.product_key }}</p>
<ul>
{% set temp_notes = item.notes|split('-') %}
{% for note in temp_notes %}
<li> {{ note }} </li>
{% endfor %}
</ul>
</td>
But for some reason the split function does not work. It seems like
{% set temp_notes = item.notes|split('-') %}
returns nothing. The dash ist not the problem. I also tried different characters to seperat.I also tried
{% set temp_notes = item.notes|split('') %}
which should result in a separation after every character. But again the split returns nothing.
Any ideas or hints?
UPDATE:
I learnt that the split function is not active. I wonder if this is true only for the self-hosted version or for the hosted version too.
I am surprised that the split function is not active. If the twig module is used anyway, why is it disabled.
Another problem
I built a custom design with some statement in the <ninja>
environment. In the preview everything works just fine and looks as I wanted it. The preview is based on a real quote. But when I look at the pdf of my quote in “normal operation” it looks like everything inside the ninja
section is skipped.
I do not understand that. I would expect that both the preview and the real generation use the same pdf engine.
Since my code works fine in the preview I think I have no syntax errors. This is the coede which is completely skipped:
<ninja>
{% set invoice = invoices|first %}
{% if invoice %}
<table width="100%" cellspacing="0px" cellpadding="0px" class="tp-table01">
<thead>
<tr>
<th> $product.product1_label </th>
<th> $item_label/$product.description_label </th>
<th> $product.product2_label </th>
<th> $product.unit_cost_label </th>
<th> $quantity_label </th>
<th> $product.discount_label</th>
<th> $product.line_total_label</th>
</tr>
</thead>
<tbody>
{% for item in invoice.line_items|filter(item => item.type_id == 1) %}
<tr>
<td>{{ item.custom_value1 }}</td>
<td>
<p class="tp-item">{{ item.product_key }}</p>
<p>{{ item.notes|nl2br }} </p>
</td>
<td>{{ item.custom_value2 }} </td>
<td>{{ item.cost }} </td>
<td>{{ item.quantity }} </td>
<td>{{ item.discount }} </td>
<td>{{ item.line_total }} </td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</ninja>
Thanks for any hints