JavaScript Templating Engine
Posted
by Randy Gurment
on Stack Overflow
See other posts from Stack Overflow
or by Randy Gurment
Published on 2010-04-18T16:00:06Z
Indexed on
2010/04/18
16:03 UTC
Read the original article
Hit count: 332
JavaScript
Hi,
I would like to create universal templating engine in JavaScript, how to?
HTML template
<h1><%title1%></h1>
<h2><%title2%></h2>
JSON file
{
"title1" : "Hello World!",
"title2" : "Hi World!"
}
Javascript
- Find in HTML file <%title1%>
- Find in JSON file variable "title1"
- Replace <%title1%> with value of variable "title1"
Same for <%title2%>
Thanks!
© Stack Overflow or respective owner