How to use functions with artTemplate and express

node environment artTemplate with express how to use the function
want to use the filter of art-template
examples given on the official website
template.defaults.imports.dateFormat = function (date, format) {/ [code..] /};
template.defaults.imports.timestamp = function (value) {return value * 1000};
but template is not defined

is reported when quoted in the template.

do you want to expose template, somewhere so that it can be used in templates?
the development environment is as follows

windows 7 64bit Chinese version
node v8.11.1
npm 5.6.0
express 4.16.0


or how to use functions in templates without filters. FcName ({{I}}) function name, which is not feasible to write in the template. I don't know what to do with the data in the template.

now that you know how to use the filter, add var defaults = require ('art-template/lib/defaults') to the app.js;
in this case template.defaults.imports.transNumber = function (number) {

return "";

}

you can use < td > {{I | transNumber}} < / td >

directly in the template.
Menu