If you can't use a serve-side technology, or something that compiles to html as Haml, and you want to use javascript and html... with a little help of jquery so you don´t have reinvent the wheel....
One solution would be to hide the html that you use as template. Then, using jquery (or other library or vanilla javascript) grab it as a string, do the replacements, and then insert the resulting string as html into the dom.
Here is a quick example with just three iterations. You will need to populate the specific data of each repetition. I use a list of objects, as the data.
If I were you I would use a library like Knockout, Angular, or Mustache.
// Data of each iteration
var data = [
{name: 'Pikachu', dex: 'pikachuDex', typeA: 'pikachuA', typeB: 'pikachuB'},
{name: 'Charmander', dex: 'charmanderDex', typeA: 'charmanderA', typeB: 'charmanderB'},
{name: 'Ratata', dex: 'ratataDex', typeA: 'ratataA', typeB: 'ratataB'}
];
// Get the template
var template = $(".pokeFloat").html();
// Iterate over data, customize template, append to html
for(var i = 0; i < data.length; i++) {
var str = template.replace(/typeA/gi, data[i].typeA);
str = str.replace(/typeB/gi, data[i].typeB);
str = str.replace(/pokemonName/gi, data[i].name);
str = str.replace(/pokeDex/gi, data[i].dex);
$("#list_of_pokemones").append(str)
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pokeFloat" style="display: none">
<div class="pokeDec">
<p>
<img class="pokeImg" src="./img/pokeDex#.jpg" />
<br>
<small>PokeDex#</small>
<br>pokemonName
<br>
<span class="typeA">TypeA</span class="TypeA"> - <span class="TypeB">TypeB</span class="TypeB">
</p>
</div>
</div>
<div id="list_of_pokemones">
</div>
Please, note that I hid the template using display: none
, and added a new div
as placeholder for the dynamically generated html.
It is not the best solution, but should give you an idea about how to do it.