I want to add this custom formatter that @Teodor made in other topic. I have read all the documentation but still unclear how to add it to the UI. After several hours of trying is any video or tutorial about how to achieve this?? Any help will be welcome.
<script>
dmx.Formatters('string', {
nl2br: function(string) {
return string.replace(/\n/g, '<br>');
}
});
</script>
<p dmx-html="pck_description.nl2br()"></p>
Thats the documentation that I dont understand… hehe this is much complex for my knowledge.
franse
March 16, 2024, 5:56pm
4
You can place the script on the page and then use the format.
For example:
I have a paragraph linked:
This will return:
So I put the script:
<script>
dmx.Formatter('object', 'stringify',
function stingfy(val) {
return JSON.stringify(val);
})
</script>
And change the paragraph:
From: <p>{{serverconnect1.state}}</p>
To: <p>{{serverconnect1.state.stringify()}}</p>
And now the result is:
Of course this is an example, but you can play with this.
Also you can put it on a js file outside the page:
1 Like
As long as I read you can add this formatter to wappler UI for later use it.
franse
March 16, 2024, 6:48pm
6
Chackmool:
how to add it to the UI
Sorry I didn’t realize that you need it in the UI.
Never done that
sid
March 18, 2024, 2:07pm
7
Here’s the documentation for doing this: