Mustache JS Template with JSON Collection

后端 未结 3 1967
眼角桃花
眼角桃花 2020-12-21 15:43

Hi this is my first attempt to use MustacheJS with a JSON webservice in .net

Currently I am struggling I can\'t seem to find what I am doing wrong setting this basic

3条回答
  •  粉色の甜心
    2020-12-21 16:33

    short answer: YES

    long answer: for security reasons [1], you need to wrap your JSON aray in an object anyways. for Mustache or any other library to be able to access your array you need to have at least one parent key on which you can base your iterator.
    The "repo" key on your sample is the helper you need to tell mustache "go and iterate on the array that is inside the repo key", otherwise you have no way to tell the template what you want to output where

    [1] this is just one of many resources you can find about why you need to wrap your JSON response in an object http://incompleteness.me/blog/2007/03/05/json-is-not-as-safe-as-people-think-it-is/

提交回复
热议问题