mirror of
https://gitee.com/DotNetNext/ReZero.git
synced 2025-12-06 08:58:54 +08:00
修改DEMO
This commit is contained in:
@@ -49,7 +49,7 @@ namespace ReZero.TextTemplate
|
||||
output.AppendLine("result");
|
||||
var result = CSharpScript.EvaluateAsync<string>(output.ToString(), options, data).GetAwaiter().GetResult();
|
||||
output.Clear();
|
||||
output.AppendLine(result);
|
||||
output.Append(result);
|
||||
}
|
||||
catch (CompilationErrorException e)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ Console.ReadLine();
|
||||
|
||||
static string Demo1()
|
||||
{
|
||||
Print("demo1");
|
||||
var x = new TextTemplateManager();
|
||||
var template = @"<div>{ {condition.ToString().ToUpper()}}</div>
|
||||
<% foreach(var item in collection) { %>
|
||||
@@ -20,6 +21,7 @@ static string Demo1()
|
||||
}
|
||||
static string Demo2()
|
||||
{
|
||||
Print("demo2");
|
||||
var x = new TextTemplateManager();
|
||||
var template = @" { { condition } }";
|
||||
var data = new Model { condition = true, collection = new[] { "Item 1", "Item 2", "Item 3" } };
|
||||
@@ -28,10 +30,17 @@ static string Demo2()
|
||||
}
|
||||
static string Demo3()
|
||||
{
|
||||
Print("demo3");
|
||||
var x = new TextTemplateManager();
|
||||
var template = @" < % var id=1; % >
|
||||
var template = @"< % var id=1; % >
|
||||
{{id}}+{{true}}";
|
||||
var data = new Model { condition = true, collection = new[] { "Item 1", "Item 2", "Item 3" } };
|
||||
var str = x.RenderTemplate(template, data);
|
||||
return str;
|
||||
}
|
||||
|
||||
static void Print(string name)
|
||||
{
|
||||
Console.WriteLine("-----"+name+ "-----");
|
||||
Console.WriteLine();
|
||||
}
|
||||
Reference in New Issue
Block a user