M
M
MaxRumata2016-08-21 18:01:16
JavaScript
MaxRumata, 2016-08-21 18:01:16

How to load HTML content from JSON file using Handlebars?

I need HTML content to be loaded from JSON file using Handlebars template . Not the whole page, but only filling content in the right place.
This approach is new for me, at the moment I managed to make it so that the content is loaded into HTML from an external javascript file. Here is an example: https://jsfiddle.net/mx4qLddz/
How to implement the same via JSON?
I heard that there are two ways, using a local server and using AJAX. The examples that I found are not yet clear to me, and this bundle needs to be implemented today. I would be very grateful for an example that demonstrates "on the fingers" what code should be in which file (and how the files are linked), so that in the end, say in HTML, let's say text and an image from a JSON file are loaded into Handlebars tempalte?
Important:
In the end, the web page will be an NPM package
. The http server is already installed (using the npm install http-server command).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question