const Express = the require ( ' Express ' ) const path = the require ( ' path ' ) const Template = the require ( ' art-Template ' ) const App = Express () // set the template primer, view documents art suffix App. SET ( ' engine View ' , ' Art ' ) // use express compatible art-template template engine app.engine ( ' Art ' , The require ( ' express-art-template ' )) App.GET ( ' / List ' , (REQ, RES) => { the let Data = { title: ' fruit ' , List: [ ' Apple ' , ' Orange ' , ' Banana ' ] } // parameter a, name of the template ; two rendering data parameter template res.render ( ' List ' , data); }) app.listen ( 3000 , () => { the console.log ( ' running .... ' ) })
// Create a view folders in the current directory
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div>{{title}}</div> <div> <ul> {{each list}} <li>{{$value}}</li> {{/each}} </ul> </div> </body> </html>
Add list.art file