Skip to content

Commit 45f55a4

Browse files
committed
want to make a simple template
1 parent 0f463b4 commit 45f55a4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

k-template/parse.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* support if else for while
3+
*/
4+
const AST = {}
5+
const ifRegExp =
6+
/**
7+
* <ul {{% %}}
8+
* <li for(var i = 0;i<3;i++){ >
9+
*
10+
* <{{% } %}}/li>
11+
* </ul>
12+
*/
13+
14+
function initString(){
15+
16+
}
17+
18+
function load(){
19+
20+
}
21+
22+
function xssEscape(string) {
23+
return [
24+
["&", "&amp;"],
25+
[" ", "&nbsp;"],
26+
["<", "&lt;"],
27+
[">", "&gt;"],
28+
["\r\n", "<br/>"],
29+
["\n", "<br/>"],
30+
["\"", "&quot;"],
31+
].reduce(
32+
function(string, [pattern, replacement]) {
33+
return string.replace(new RegExp(pattern, "g"), replacement);
34+
}, string);
35+
}

0 commit comments

Comments
 (0)