{"id":19046,"date":"2017-11-01T12:14:34","date_gmt":"2017-11-01T10:14:34","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=19046"},"modified":"2017-11-01T10:19:22","modified_gmt":"2017-11-01T08:19:22","slug":"using-mustache-js-client-side-templating","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/","title":{"rendered":"Using Mustache.js for Client-Side Templating"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>In this article, I will show you how to make use of <a href=\"https:\/\/github.com\/janl\/mustache.js\">Mustache.js<\/a> for client-side templating. In this approach, we get the JSON data from an API, developed by you or a 3rd party API and build the HTML required for rendering the data at the client side.<\/p>\n<p>We will make use of GitHub APIs to demonstrate this technique.<\/p>\n<h2>Understanding GitHub APIs<\/h2>\n<p>We will use the following GitHub APIs:<\/p>\n<ol>\n<li>Get user detail: this API will return the public information for a given user, for example, <a href=\"https:\/\/api.github.com\/users\/google\" rel=\"nofollow\">https:\/\/api.github.com\/users\/google<\/a><\/li>\n<li>Get public repositories for user ordered by most stars first, for example, <a href=\"https:\/\/api.github.com\/search\/repositories?q=user:google&amp;sort=stars&amp;per_page=10\" rel=\"nofollow\">https:\/\/api.github.com\/search\/repositories?q=user:google&amp;sort=stars&amp;per_page=10<\/a><\/li>\n<\/ol>\n<h2>Setting up the Javascript and CSS Dependencies<\/h2>\n<p>We will make use of the following CSS and Javascript dependencies:<\/p>\n<ol>\n<li>Bootstrap based simple theme\u00a0https:\/\/bootswatch.com\/default\/<\/li>\n<li>Font Awesome icons\u00a0http:\/\/fontawesome.io\/<\/li>\n<li>jQuery\u00a0https:\/\/jquery.com<\/li>\n<li>Mustache.js\u00a0https:\/\/github.com\/janl\/mustache.js<\/li>\n<\/ol>\n<p>The basic HTML for this is given below:<\/p>\n<pre class=\"brush:xml\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;title&gt;Mustache Demo&lt;\/title&gt;\r\n        &lt;link rel=\"stylesheet\" type=\"text\/css\" \r\n         href=\"https:\/\/bootswatch.com\/bower_components\/bootstrap\/dist\/css\/bootstrap.min.css\" \/&gt;\r\n        &lt;script src=\"https:\/\/use.fontawesome.com\/e344ad35b2.js\"&gt;&lt;\/script&gt;\r\n        &lt;style type=\"text\/css\"&gt;\r\n            .git-user-avatar {\r\n                width: 100px;\r\n                height: 100px;\r\n            }\r\n            .center{\r\n                text-align: center;\r\n                padding-top: 5px;\r\n            }\r\n            .space{\r\n                margin-top: 10px;\r\n            }\r\n            .git-stars{\r\n                color: goldenrodyellow;\r\n            }\r\n        &lt;\/style&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;div class=\"container\"&gt;&lt;\/div&gt;\r\n        &lt;script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.2.1\/jquery.min.js\"&gt;&lt;\/script&gt;\r\n        &lt;script src=\"https:\/\/bootswatch.classom\/bower_components\/bootstrap\/dist\/js\/bootstrap.min.js\"&gt;&lt;\/script&gt;\r\n        &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/mustache.js\/2.3.0\/mustache.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h2>GitHub Username Selection<\/h2>\n<p>First, let us populate few usernames in a <code>select<\/code> component as shown below:<\/p>\n<pre class=\"brush:xml\">&lt;div class=\"row\"&gt;\r\n    &lt;div class=\"col-md-offset-3 col-md-6\"&gt;\r\n        &lt;h3&gt;Select user&lt;\/h3&gt;\r\n        &lt;select id=\"git-users\" class=\"form-control\"&gt;\r\n            &lt;option value=\"\"&gt;&lt;\/option&gt;\r\n            &lt;option value=\"facebook\"&gt;Facebook&lt;\/option&gt;\r\n            &lt;option value=\"google\"&gt;Google&lt;\/option&gt;\r\n            &lt;option value=\"netflix\"&gt;Netflix&lt;\/option&gt;\r\n            &lt;option value=\"flipkart\"&gt;Flipkart&lt;\/option&gt;\r\n            &lt;option value=\"amzn\"&gt;Amazon&lt;\/option&gt;\r\n            &lt;option value=\"microsoft\"&gt;Microsoft&lt;\/option&gt;\r\n        &lt;\/select&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>Next is to provide a <code>onChange<\/code> event handler as shown below:<\/p>\n<pre class=\"brush:js\">$(function() {\r\n    $(\"#git-users\").on('change', function(){\r\n        var username = $(this).val();\r\n        \/\/TODO: get user detail and most starred repos\r\n    });\r\n});<\/pre>\n<h2>Defining Mustache Template for User Detail<\/h2>\n<p>Let us create a place holder for adding the user detail as shown:<\/p>\n<pre class=\"brush:xml\">&lt;div class=\"row\"&gt;\r\n    &lt;div class=\"col-md-offset-3 col-md-6\" id=\"git-user-detail\"&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>Next up is to define the Mustache template as shown below:<\/p>\n<pre class=\"brush:xml\">&lt;script type=\"text\/html\" id=\"git-user-detail-template\"&gt;\r\n    &lt;div class=\"center\"&gt;\r\n        &lt;img src=\"{{avatar_url}}\" class=\"git-user-avatar\" \/&gt;\r\n        &lt;div class=\"space\"&gt;&lt;\/div&gt;\r\n        Github User &lt;a href=\"{{html_url}}\"&gt;{{login}}&lt;\/a&gt;\r\n        &lt;div class=\"space\"&gt;&lt;\/div&gt;\r\n        Name &lt;a href=\"{{blog}}\"&gt;{{name}}&lt;\/a&gt;\r\n        {{#bio}}\r\n        &lt;div class=\"space\"&gt;&lt;\/div&gt;\r\n        {{bio}}\r\n        {{\/bio}}\r\n    &lt;\/div&gt;\r\n&lt;\/script&gt;<\/pre>\n<p>Let us write the javascript which does an Ajax call to GitHub API and renders the data using Mustache template created above:<\/p>\n<pre class=\"brush:js\">function getUserDetail(username){    \r\n    $.getJSON('https:\/\/api.github.com\/users\/'+username, function(data){\r\n        var html = Mustache.to_html(\r\n          $(\"#git-user-detail-template\").html(), data);\r\n        $(\"#git-user-detail\").html(html);\r\n    });\r\n}<\/pre>\n<h2>Defining Mustache Template for User Repos<\/h2>\n<p>First let us see the placeholder for the data:<\/p>\n<pre class=\"brush:xml\">&lt;div class=\"row\"&gt;\r\n    &lt;div class=\"col-md-offset-3 col-md-6\" \r\n        id=\"git-user-repos\"&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>Next up is the Mustache template:<\/p>\n<pre class=\"brush:xml\">&lt;script type=\"text\/html\" id=\"git-user-repos-template\"&gt;\r\n    &lt;ul class=\"list-group\"&gt;\r\n        {{#items}}\r\n        &lt;li class=\"list-group-item\"&gt;\r\n            &lt;span class=\"badge\"&gt;\r\n                &lt;i class=\"fa fa-star git-stars\"&gt;&lt;\/i&gt; {{stargazers_count}}\r\n            &lt;\/span&gt;\r\n            &lt;a href=\"{{html_url}}\"&gt;{{full_name}}&lt;\/a&gt;\r\n        &lt;\/li&gt;\r\n        {{\/items}}\r\n    &lt;\/ul&gt;\r\n&lt;\/script&gt;<\/pre>\n<p>And finally the javascript code to load the data via Ajax and render the data using the above template:<\/p>\n<pre class=\"brush:js\">function getMostStarredRepos(username){\r\n    $.getJSON('https:\/\/api.github.com\/search\/repositories?q=user:'\r\n        +username+'&amp;sort=stars&amp;per_page=10', function(data){\r\n        $(\"#git-user-repos\").html(Mustache.to_html(\r\n            $(\"#git-user-repos-template\").html(), data));\r\n    });\r\n}<\/pre>\n<p>I created a small helper function and Mustache template for showing the loading message while we wait for the Ajax call to complete. The Mustache template for that is:<\/p>\n<pre class=\"brush:xml\">&lt;script type=\"text\/html\" id=\"loading-template\"&gt;\r\n    &lt;div class=\"alert alert-info center\"&gt;\r\n        &lt;i class=\"fa fa-spinner fa-spin\"&gt;&lt;\/i&gt; Loading ...\r\n    &lt;\/div&gt;\r\n&lt;\/script&gt;<\/pre>\n<p>And the Javascript method that uses the above template and renders the message is:<\/p>\n<pre class=\"brush:js\">function loading(target){\r\n    $(target).html(Mustache.to_html(\r\n        $(\"#loading-template\").html(), {}));\r\n}<\/pre>\n<h2>Conclusion<\/h2>\n<p>In this small article, we saw how to make use of Mustache based client side templates to render the data obtained via REST APIs invoked asynchronously. The complete HTML for this can be found <a href=\"https:\/\/github.com\/sanaulla123\/samples\/blob\/master\/mustache-demo.html\">here<\/a>.<\/p>\n<p>Some screenshots of the sample. Below is while loading the data:<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/11\/11.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-19049\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/11\/11.png\" alt=\"\" width=\"621\" height=\"255\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/11\/11.png 621w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/11\/11-300x123.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/11\/11-620x255.png 620w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><\/a><\/p>\n<p>Below is after the data has been rendered using Mustache templates:<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/11\/21.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-19050\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/11\/21.png\" alt=\"\" width=\"591\" height=\"478\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/11\/21.png 591w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/11\/21-300x243.png 300w\" sizes=\"(max-width: 591px) 100vw, 591px\" \/><\/a><\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>Published on Web Code Geeks with permission by Mohamed Sanaulla, partner at our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener\">WCG program<\/a>. See the original article here: <a href=\"https:\/\/sanaulla.info\/2017\/10\/31\/using-mustache-js-for-client-side-templating\/\" target=\"_blank\" rel=\"noopener\">Using Mustache.js for Client-Side Templating<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In this article, I will show you how to make use of Mustache.js for client-side templating. In this approach, we get the JSON data from an API, developed by you or a 3rd party API and build the HTML required for rendering the data at the client side. We will make use of GitHub &hellip;<\/p>\n","protected":false},"author":3,"featured_media":920,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[496],"class_list":["post-19046","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-mustache-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using Mustache.js for Client-Side Templating - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Introduction In this article, I will show you how to make use of Mustache.js for client-side templating. In this approach, we get the JSON data from an\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Mustache.js for Client-Side Templating - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Introduction In this article, I will show you how to make use of Mustache.js for client-side templating. In this approach, we get the JSON data from an\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-11-01T10:14:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mohamed Sanaulla\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mohamed Sanaulla\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/\"},\"author\":{\"name\":\"Mohamed Sanaulla\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/25d8251ab46cf28d12fa1ef1d02d22d1\"},\"headline\":\"Using Mustache.js for Client-Side Templating\",\"datePublished\":\"2017-11-01T10:14:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/\"},\"wordCount\":432,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"keywords\":[\"Mustache.js\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/\",\"name\":\"Using Mustache.js for Client-Side Templating - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"datePublished\":\"2017-11-01T10:14:34+00:00\",\"description\":\"Introduction In this article, I will show you how to make use of Mustache.js for client-side templating. In this approach, we get the JSON data from an\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Using Mustache.js for Client-Side Templating\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/25d8251ab46cf28d12fa1ef1d02d22d1\",\"name\":\"Mohamed Sanaulla\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g\",\"caption\":\"Mohamed Sanaulla\"},\"sameAs\":[\"http:\/\/blog.sanaulla.info\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/mohamed-sanaulla\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Mustache.js for Client-Side Templating - Web Code Geeks - 2026","description":"Introduction In this article, I will show you how to make use of Mustache.js for client-side templating. In this approach, we get the JSON data from an","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/","og_locale":"en_US","og_type":"article","og_title":"Using Mustache.js for Client-Side Templating - Web Code Geeks - 2026","og_description":"Introduction In this article, I will show you how to make use of Mustache.js for client-side templating. In this approach, we get the JSON data from an","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-11-01T10:14:34+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","type":"image\/jpeg"}],"author":"Mohamed Sanaulla","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Mohamed Sanaulla","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/"},"author":{"name":"Mohamed Sanaulla","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/25d8251ab46cf28d12fa1ef1d02d22d1"},"headline":"Using Mustache.js for Client-Side Templating","datePublished":"2017-11-01T10:14:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/"},"wordCount":432,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","keywords":["Mustache.js"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/","name":"Using Mustache.js for Client-Side Templating - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","datePublished":"2017-11-01T10:14:34+00:00","description":"Introduction In this article, I will show you how to make use of Mustache.js for client-side templating. In this approach, we get the JSON data from an","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/using-mustache-js-client-side-templating\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Using Mustache.js for Client-Side Templating"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/25d8251ab46cf28d12fa1ef1d02d22d1","name":"Mohamed Sanaulla","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g","caption":"Mohamed Sanaulla"},"sameAs":["http:\/\/blog.sanaulla.info"],"url":"https:\/\/www.webcodegeeks.com\/author\/mohamed-sanaulla\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/19046","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=19046"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/19046\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/920"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=19046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=19046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=19046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}