【发布时间】:2015-07-20 00:43:34
【问题描述】:
我有一个项目需要我使用下划线模板。
假设应用程序从 API 获取配方并将其呈现到页面。 如果用户喜欢这个食谱,他们就可以将其保存以备后用。
谁能帮我解决这个问题?我不确定是否应该从客户端或服务器完成请求。另外,我不太确定从 API (JSON) 返回的数据将如何呈现到页面。
下面是我在 API 上使用 postman 得到的 JSON 对象:
{"recipe": {
"publisher": "Closet Cooking",
"f2f_url": "http://food2fork.com/view/35171",
"ingredients": [
"1/4 cup cooked shredded chicken, warm",
"1 tablespoon hot sauce",
"1/2 tablespoon mayo (optional)",
"1 tablespoon carrot, grated",
"1 tablespoon celery, sliced",
"1 tablespoon green or red onion, sliced or diced",
"1 tablespoon blue cheese, room temperature, crumbled",
"1/2 cup cheddar cheese, room temperature, grated",
"2 slices bread",
"1 tablespoon butter, room temperature\\\n"
],
"source_url": "http://www.closetcooking.com/2011/08/buffalo-chicken-grilled-cheese-sandwich.html",
"recipe_id": "35171",
"image_url": "http://static.food2fork.com/Buffalo2BChicken2BGrilled2BCheese2BSandwich2B5002B4983f2702fe4.jpg",
"social_rank": 100,
"publisher_url": "http://closetcooking.com",
"title": "Buffalo Chicken Grilled Cheese Sandwich"}}
【问题讨论】:
标签: javascript templates underscore.js