Skip to content

Instantly share code, notes, and snippets.

@dsdstudio
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsdstudio/5f60d28f38a8a2fba74b to your computer and use it in GitHub Desktop.
Save dsdstudio/5f60d28f38a8a2fba74b to your computer and use it in GitHub Desktop.
간단한 한줄짜리 jsp style 템플릿 엔진
/**
* 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
@dsdstudio
Copy link
Author

변수명 잘못되어있던 부분 수정

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment