Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. function solve() {
  2. document.getElementById('btnLoadTowns').addEventListener('click', main)
  3.  
  4. async function main() {
  5. const towns = document.getElementById('towns').value.split(', ');
  6. const source = await fetch('http://127.0.0.1:5500/JS%20Applications/Exercise%20-%20Templating/01.%20List%20Towns/towns.hbs')
  7. .then(res => res.text())
  8. .then(res => console.log(res));
  9.  
  10. const template = Handlebars.compile(source);
  11.  
  12. const html = template({ towns });
  13. const div = document.getElementById('root')
  14.  
  15. div.innerHTML = html;
  16. }
  17. }
  18. solve()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement