function to be use in Custom template Body of List Page

First time to create function to use in Custom template Body of List Page
On the Client Side → List Page → Client Script
$.views.converters(“statuscolor”, function(val) {
if(val == 1)return “info”;
else if(val == 2)return “danger”;
else return “success”;
});

And on the Custom Template Body I try to use the function as
{{statuscolor:2 }}

But I did not get the value “danger”

Read: https://www.jsviews.com/#samples/jsr/converters

Thanks for your reply and sharing the link
I have gone through the code still unable to resolve

Where I have put the below code, in the client script or startup script or global code
$.views.converters({
statuscolor: function(value) {
return result;
}
});

how do i get the value in the custom template of list page.
I try as
{{statuscolor:success}}
${{statuscolor:success}}

Please kindly guide where I have made the mistake.
Thanks for helping in advance.

You better declare your converters in Page_Head server event, e.g.

On the page Head server event I have put the code as

And on the List Custom Template I try to use the function as
{{statuscolor:oknow}}

but it show the blank page

Blank page usually implies server side PHP error (not client side JavaScript error which you can check by F12 → Console), you better configure your php.ini to display all errors.

arbei wrote:

Blank page usually implies server side PHP error (not client side JavaScript error
which you can check by F12 → Console)

The error occurs when I put the
{{statuscolor:oknow}}
but it works normal when I remove it

By pressing the F12
there is an error showing at

saying that
Uncaught ReferenceError: $ is not defined

singh wrote:

Uncaught ReferenceError: $ is not defined

Do it after jQuery and JsRender is loaded, e.g.

loadjs.ready(“jsrender”, function() {

});

On the page Head I write the code as

And on the List Custom Template I try to use the function as
{{statuscolor:oknow}}

Now there is no error on the page but unable to get the return function value by using
{{statuscolor:oknow}}

{{statuscolor:oknow}}

What is “oknow”? There is no such value in Custom Template. If “oknow” is a field name, you may try {{{dbvalue oknow}}}.