You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've trying to set a string which concat integer variables with strings and other string variables, like this example below:
page.json.coupons is an array of objecsts
{% set page.config.description=length(page.json.coupons) + " found coupons to " + storeJson.store_name %}
But this exceptions is raising: [json.exception.type_error.302] type must be number, but is string
I did a workaround which is not the better idea, but it's working for know. But in the future I want to create a function to convert numbers to string so I can concat numbers with strings.
The ugly workaround I did:
{# Workaround to convert a number to string. TODO create a function to do that #}
{% set couponsArray = [0] %}
{% set couponsArray.0 = length(page.json.coupons) %}
{% set couponsLength = join(couponsArray, "") %}
{# Workaround end #}
{% set page.config.description=couponsLength + " found coupons to " + storeJson.store_name %}
Any thoughts on this?
The text was updated successfully, but these errors were encountered:
There are already functions to convert strings to numbers https://github.com/pantor/inja#functions
So it would be nice to have also a function which converts numbers to strings.
I've trying to set a string which concat integer variables with strings and other string variables, like this example below:
page.json.coupons
is an array of objecstsBut this exceptions is raising:
[json.exception.type_error.302] type must be number, but is string
I did a workaround which is not the better idea, but it's working for know. But in the future I want to create a function to convert numbers to string so I can concat numbers with strings.
The ugly workaround I did:
Any thoughts on this?
The text was updated successfully, but these errors were encountered: