I am using JSON and MUSTACHE for templates in my new site. But I do not know how I can get HTML from JSN data. I am using PHP in backend, which is working as an API provider. I am very new to this concept. Awe help and suggestions are welcome.
Thank you.
Using the code
& lt; Script & gt; // This is the basis for this. Get (/\#\/(.*)/, function () {var send_url = '& lt ;? php echo $ url? & Gt; Sammy /' + this.params ['splat']; var reference = this ; $ .getJSON (send_url, function) {var template = data.template; context.renderEach ('& lt ;? php echo $ url? & Gt; mustache templates /' + template + ', data .data). Swap ();});}); & Lt; / Script & gt; Like JSON data: {"menu": {"id": "file", "string": "& lt; a href = \" http: \ / \ / stackoverflow .com \ question / \ 5335873 \ / how to get -html-to-json-data-use-shouldache # xyz \ "& gt; string & lt; / a & gt;",}} MUSTACHE template:
{{# string}} & lt; Div & gt; {{String}} & lt; / Div & gt; {{/ String}} Current output:
& lt; A href = "https://stackoverflow.com/questions/5335873/how-to-mill-html-to-json-data usage-mustache # xyz" & gt; String & lt; / A & gt; Requirement of output:
thanks
Current output:
& lt; A href = "http://stackoverflow.com/questions/5335873/how-to-get-html-s-json-Usage-Seek # xyz" & gt; String & lt; / A & gt; This is not output. What do you really get
and Of course it looks like what you have posted in the browser. Munshi HTML avoids all your variables by default, so they do not mess up your HTML.
In this case, you do not want this, so you should use the {{{string}}}. Be sure to do the same with the dependable variable in the template, never use it for any user input.
Comments
Post a Comment