a little question about erazor https://github.com/ciscoheat/erazor i know this framwork is based on Razor template engine. http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx
i noticed the api doesn't fit exactly with Razor (ex: @for(a in p) differs from RAZOR)
this template system for haxe is very handy... i just don't know how to setup a variable like we do in templo ( :: set mock="tada!":: )
//@scope is mycontroller;
@{var mock = scope.getMock()}
@if(mock!=null){
//display some html
}
开发者_高级运维
any tips ? thx
The following snippet works:
import erazor.Template;
import neko.Lib;
class Main {
static function main() {
var template = new Template("@{var mock = scope.getMock();} @if (mock != null) { @mock }");
Lib.print(template.execute( { scope : { getMock : function() return "hi" } } ));
}
}
What you missed is that inside a code block all the statements must be correctly closed (missing ;
). Also erazor is loosely based on Razor and uses the Haxe syntax for expressions.
精彩评论