Skip to content

Instantly share code, notes, and snippets.

@robbinhan
Created April 18, 2016 09:21
Show Gist options
  • Save robbinhan/bbd49cd352b3169cebfb6414bee6484b to your computer and use it in GitHub Desktop.
Save robbinhan/bbd49cd352b3169cebfb6414bee6484b to your computer and use it in GitHub Desktop.
'use strict'
let html = "<title>{{title}}</title><div>{{content}}</div><div>{{content}}</div><div>{{content}}</div><div>{{content}}</div>"
const data = {
title:"Test",
content:"Hello World"
}
for(let k in data) {
let v = data[k]
let patten = `{{${k}}}`
let re = new RegExp(patten,"g");
html = html.replace(re,v);
}
console.log(html);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment