Created
December 13, 2012 13:50
-
-
Save juner/4276478 to your computer and use it in GitHub Desktop.
Hello RND templateEngine
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
RND templateEngineの Hello Worldでも。 | |
元ネタ的には | |
http://amix.dk/blog/viewEntry/163 | |
なのだけれど、使ってる人って居るんかな。 | |
test1 | |
$(X)で囲った箇所を指定した変数によって置き換えてます。 | |
test2 | |
$(X|func)の形式でfunc(X)を実現してます。 | |
以上! |
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
body { background-color: #DDDDDD; font: 30px sans-serif; } |
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
<div id="test1"><span>%(H)%(W)</span><span>%(RND)</span></div> | |
<div id="test2"><span>%(value)*2=%(value|timesTwo)</span></div> |
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
{//test1 | |
var test1 = jQuery("#test1"); | |
var template = test1.html(); | |
var values ={ | |
"H":"Hello ", | |
"W":"World ", | |
"RND":"RND Template Engine" | |
}; | |
var output = RND(template,values); | |
test1.html(output); | |
}{//test2 | |
var test2 = jQuery("#test2"); | |
var template = test2.html(); | |
var values = { | |
"value":5.5 | |
}; | |
var funcs = { | |
"timesTwo":function(v){ | |
return v*2; | |
} | |
}; | |
var output = RND(template,values,funcs); | |
test2.html(output); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment