-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerator.cs
33 lines (28 loc) · 1.02 KB
/
Generator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using FlatBufferEx.Model;
using Scriban;
namespace FlatBufferEx
{
public static class Generator
{
private static readonly Template RawTableTemplate = Template.Parse(File.ReadAllText("Template/raw.table.txt"));
private static readonly Template RawEnumTemplate = Template.Parse(File.ReadAllText("Template/raw.enum.txt"));
public static string RawFlatBufferTableContents(Model.Table table, string lang)
{
var obj = new ScribanEx();
obj.Add("table", table);
obj.Add("lang", lang);
var ctx = new TemplateContext();
ctx.PushGlobal(obj);
return RawTableTemplate.Render(ctx);
}
public static string RawFlatBufferEnumContents(Model.Enum e, string lang)
{
var obj = new ScribanEx();
obj.Add("enum", e);
obj.Add("lang", lang);
var ctx = new TemplateContext();
ctx.PushGlobal(obj);
return RawEnumTemplate.Render(ctx);
}
}
}