[fix] 修复使用Scriban导出大型文本型数据时发生超出最大迭代次数的问题
parent
7ad942b7cd
commit
16e4fe2452
|
|
@ -1,6 +1,7 @@
|
||||||
using Luban.Job.Cfg.Datas;
|
using Luban.Job.Cfg.Datas;
|
||||||
using Luban.Job.Cfg.Defs;
|
using Luban.Job.Cfg.Defs;
|
||||||
using Luban.Job.Cfg.Utils;
|
using Luban.Job.Cfg.Utils;
|
||||||
|
using Luban.Job.Common.Utils;
|
||||||
using Scriban;
|
using Scriban;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
|
@ -10,7 +11,7 @@ namespace Luban.Job.Cfg
|
||||||
{
|
{
|
||||||
public static string RenderCode(this Template template, object model, Dictionary<string, object> extraModels = null)
|
public static string RenderCode(this Template template, object model, Dictionary<string, object> extraModels = null)
|
||||||
{
|
{
|
||||||
var ctx = new TemplateContext();
|
var ctx = TemplateUtil.CreateDefaultTemplateContext();
|
||||||
var env = new TTypeTemplateExtends
|
var env = new TTypeTemplateExtends
|
||||||
{
|
{
|
||||||
["x"] = model,
|
["x"] = model,
|
||||||
|
|
@ -29,8 +30,7 @@ namespace Luban.Job.Cfg
|
||||||
|
|
||||||
public static string RenderDatas(this Template template, DefTable table, List<DBean> exportDatas, Dictionary<string, object> extraModels = null)
|
public static string RenderDatas(this Template template, DefTable table, List<DBean> exportDatas, Dictionary<string, object> extraModels = null)
|
||||||
{
|
{
|
||||||
var ctx = new TemplateContext();
|
var ctx = TemplateUtil.CreateDefaultTemplateContext();
|
||||||
|
|
||||||
var env = new DTypeTemplateExtends
|
var env = new DTypeTemplateExtends
|
||||||
{
|
{
|
||||||
["table"] = table,
|
["table"] = table,
|
||||||
|
|
@ -51,8 +51,7 @@ namespace Luban.Job.Cfg
|
||||||
|
|
||||||
public static string RenderData(this Template template, DefTable table, DBean data, Dictionary<string, object> extraModels = null)
|
public static string RenderData(this Template template, DefTable table, DBean data, Dictionary<string, object> extraModels = null)
|
||||||
{
|
{
|
||||||
var ctx = new TemplateContext();
|
var ctx = TemplateUtil.CreateDefaultTemplateContext();
|
||||||
|
|
||||||
var env = new DTypeTemplateExtends
|
var env = new DTypeTemplateExtends
|
||||||
{
|
{
|
||||||
["table"] = table,
|
["table"] = table,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
using Scriban;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Luban.Job.Common.Utils
|
||||||
|
{
|
||||||
|
public static class TemplateUtil
|
||||||
|
{
|
||||||
|
public static TemplateContext CreateDefaultTemplateContext()
|
||||||
|
{
|
||||||
|
return new TemplateContext()
|
||||||
|
{
|
||||||
|
LoopLimit = 0,
|
||||||
|
NewLine = "\n",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Luban.Job.Common.Utils;
|
||||||
using Luban.Job.Db.Defs;
|
using Luban.Job.Db.Defs;
|
||||||
using Scriban;
|
using Scriban;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -8,7 +9,7 @@ namespace Luban.Job.Db
|
||||||
{
|
{
|
||||||
public static string RenderCode(this Template template, object model, Dictionary<string, object> extraModels = null)
|
public static string RenderCode(this Template template, object model, Dictionary<string, object> extraModels = null)
|
||||||
{
|
{
|
||||||
var ctx = new TemplateContext();
|
var ctx = TemplateUtil.CreateDefaultTemplateContext();
|
||||||
var env = new TTypeTemplateExtends
|
var env = new TTypeTemplateExtends
|
||||||
{
|
{
|
||||||
["x"] = model
|
["x"] = model
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Luban.Job.Common.Utils;
|
||||||
using Luban.Job.Proto.Defs;
|
using Luban.Job.Proto.Defs;
|
||||||
using Scriban;
|
using Scriban;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -8,7 +9,7 @@ namespace Luban.Job.Proto
|
||||||
{
|
{
|
||||||
public static string RenderCode(this Template template, object model, Dictionary<string, object> extraModels = null)
|
public static string RenderCode(this Template template, object model, Dictionary<string, object> extraModels = null)
|
||||||
{
|
{
|
||||||
var ctx = new TemplateContext();
|
var ctx = TemplateUtil.CreateDefaultTemplateContext();
|
||||||
var env = new TTypeTemplateExtends
|
var env = new TTypeTemplateExtends
|
||||||
{
|
{
|
||||||
["x"] = model
|
["x"] = model
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue