Using Lambda Expression within MapBox TileMill Teaser

100 views Asked by At

I have the following TileMill Teaser defined:

Phone: {{{PHONE}}}

The phone data is numeric with 10 digit phone numbers. I want to format it on-the-fly using lambda expression as follows:

Phone: {{#formatPhone}}{{PHONE}}{{/formatPhone}}

In a hash, I know that formatPhone can be defined as follows:

"formatPhone" : function () {
   return function(phone) {
     // Do formatting here ...
     return phone;
   }
}

What I don't know is how to define the Lambda function within the TileMill teaser interface.

Any assistance is greatly appreciated.

Thank you

1

There are 1 answers

0
tmcw On

What I don't know is how to define the Lambda function within the TileMill teaser interface.

Lambda expressions are not supported, because they are JavaScript. If we were to permit JavaScript, it would be an easy attack vector XSS and other attacks. If you want to do this yourself, you can use the lower-level L.mapbox.gridLayer API and do the formatting in JavaScript in your own integration.