Make multiple HTML template with sample HTML and JSON array is very useful while working on long form or any other big similar content where you want to replace only few things.

This code supports infinite variables inside a sample template. Jsfiddle DEMO is below

https://jsfiddle.net/shakalya/Lux8vhfw/

Now what you have to do use #0, #1, #2 kind of variables in side a sample template and write an JSON ARRAY

var data = [[‘title’,’Title’,’Enter Title here’],[‘description’,’Description’,’Enter short description here’]];

Now this will find and replace each #0 with first element and #1 with second Element and so on.

This is very helpful while find and replacing in bulk and creating similar template structure.

STEP 1

if your template is

Now i want to make multiple copy of it with few changes. Each time i want to edit ‘title’, ‘Title’ and  ‘Put your title here’ and make so many copies of it.

So i have to saperate it into 3 variables #0, #1 and #2 and

PUT a template under div has id ‘template’

STEP 2

Create a JSON array

var data = [[‘title’,’Title’,’Enter Title here’],[‘description’,’Description’,’Enter short description here’]];

You can add multiple arrays inside to get as much copy of this result.

You can see the live example at jsfiddle below

https://jsfiddle.net/shakalya/Lux8vhfw/