I recently started using the Mustache module and noticed that in the example syntax under the variables field, it says 'Enter the array'.[{"key":"<key1>","value":"<value1>"},["key"."<key2>","value":" <value2>"},....]'
Could someone please provide an example of how to use a keyed array, as demonstrated in the example text below the field? Please demonstrate the usage of the keyed array and how to replace the handlebar items in the template with the items from the keyed array. I assume that the âkeyâ refers to what is in the handlebar, and the âvalueâ will be the result after it is replaced. I am unsure about how to properly include the array in the field. I attempted to simply drop it in using a clicked reference, but I believe it might require a map function or something similar.
To build the array you could use the add() array function as I described in a completely different use-case here.
Note though that in the case of the Mustache module, each array element is a collection. Youâd need to create the appropriate JSON object for that collection using the Create JSON module.
Thank you for the reply I created a JSON object with a collection and two items the key and value i want replace. Is this what I need? Now how do I implement from here?
If you look closely at the example syntax, youâll see that the key object needs to be named key rather than textKeyword, and the value needs to be named value rather than textReplacement.
Also, I think the key should be stated without any curly mustache braces, as shown in the help.
If you can make those changes in your Jotform that would be easiest - then you can just map the textReplacements array from the Parse JSON module straight into the Mustache module.
How about this issue? I switched the mustache text to mappable. I assume that means I placed the handlebar text inside the mapped items. As you can see in the screenshot, I tried two versions. Since I canât use double handlebars {{ }} in make.com, I attempted one version with the handlebars escaped as {{name}}. This is indicated as â1â in the screenshot. Then, I tried another version of the text using double handlebars {{name}} which transformed it into a mapped item for make, as shown as â2â in the screenshot. However, neither version worked, so I have no idea how to pass a variable of text and have it modified.
Thatâs a very good question. The Help documentation for the Mustache module doesnât mention the Mappable Template Mode, so thereâs no hints there. Iâll enquire.
However ⌠from your example it looks like youâre trying to create a JSON object. It might be simpler to use the Parse JSON module from within the JSON app.
Thank you, please let me know when you hear back about the usage syntax.
Yeah, it might be easier to use the JSON parser. However, I have a specific use case for the mustache module in this scenario, and I hope it can be utilized.
It seems that the original concept was that the mapped Template would come from some other source where the {{ and }} was already in place.
If youâre assembling the Template in a Set a Variable module then you will run into the issue of {{ and }} being treated specially by the UI. The most practical workaround for this is to use something else that doesnât get recognized by the UI and then replace it using a function.
For example, if you wanted:
{{value}}
you could instead use:
replace({{value]];];})
As the value hasnât been wrapped in curly braces it doesnât get recognized by the UI. The replace() function changes it to the correct syntax.