修改DEMO

This commit is contained in:
sunkaixuan
2024-05-25 15:21:49 +08:00
parent 94ba20d6f3
commit 675e0ce4a6
2 changed files with 11 additions and 2 deletions

View File

@@ -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)
{

View File

@@ -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();
}