Last active
August 29, 2015 14:20
-
-
Save dsdstudio/5f60d28f38a8a2fba74b to your computer and use it in GitHub Desktop.
간단한 한줄짜리 jsp style 템플릿 엔진
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* javascript jsp style micro template compiler | |
* template => <%= val %> | |
* */ | |
function compile(tpl, data) { | |
var compiledStr = '' | |
,regex = '/\<\%\=(.+?)\%\>/gim' | |
,t0; | |
while((t0 = regex.exec(compiledStr)) != null) | |
compiledStr = compiledStr.replace(new Regexp(t0[0], 'gi'), data[t0[1]]); | |
return compiledStr; | |
}; | |
compile('wFlowCheoriYn|wGwanriNo|wMyeongching|wChulweonNo|wChulweonDte<%=wJudamId%>', {wJudamId:'aaa'}); | |
// wFlowCheoriYn|wGwanriNo|wMyeongching|wChulweonNo|wChulweonDteaaa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
변수명 잘못되어있던 부분 수정