var sp = require("silly-datetime"); var render = require("koa-art-template"); var path = require("path"); var koa = require("koa"); var app = new koa(); render(app,{ root:path.join(__dirname,"views"), extname:'.jat', debug:progress.env.NODE_ENV != 'production', dateFormat:dateFormat=(value)=>{ return sp.format(new Date(value),'YYYY-MM-DD HH:mm'); } });
Use the template in jat
{{each list}} <- ! found in the database list is an array of data ->
{{$ value.datetime | the dateFormat}}! <- list array is a timestamp datetime, shown the dateFormat ->
{{/}} each