0

Many times i am asking myself how to handle Data and design. I wrote a REST API which responding data. The responding data are presenting in JSON without a design html structure of course. To display the data i have to parse them into a design.

E.g. my REST API returning me a list of flights. Now i have to design the list from json into a cool html / css structre.

I dont want to add all the stuff via Jquery. I even dont want to response the finished design via REST API.

What is the best practise for this case?

  • 1
    Doing a loop for each item of the json object, and then printing it with html to the target you want – Zander Oct 17 '17 at 10:02
  • Refer to this question https://stackoverflow.com/questions/18673860/defining-a-html-template-to-append-using-jquery – Shubham Agrawal Oct 17 '17 at 10:05
  • That means i have to write all the design things (HTML struckture) into my .done method. But actaully i want to load a template + load my data match them and presenting them. So i want to divide everything –  Oct 17 '17 at 10:05
  • then you need to find a templating engine. Lots of them around if you google. Some are part of more comprehensive frameworks such as AngularJS (just for example) but there are also some more standalone tools such as Mustache.js. You can easily find others by searching, and get one which suits you. – ADyson Oct 17 '17 at 10:23
  • if you can paste the json format here, I am sure someone will suggest you the code – Vikram Oct 17 '17 at 12:25
  • Something like that: {"status":true,"aircraft":{"id":"2","icao":"A10","manufacture_id":"2","type":"A-10 Thunderbolt 2","wtc_id":"5","owe":"0","mtow":"0","display":"1","date":"2017-06-23 18:04:59","cost_index":35}} –  Oct 17 '17 at 14:01

0 Answers0