forked from sebastienros/fluid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TemplateOptions.cs
89 lines (73 loc) · 3.13 KB
/
TemplateOptions.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using Fluid.Filters;
using Fluid.Values;
using Microsoft.Extensions.FileProviders;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
namespace Fluid
{
public class TemplateOptions
{
public static readonly TemplateOptions Default = new();
/// <summary>
/// Gets ot sets the members than can be accessed in a template.
/// </summary>
public MemberAccessStrategy MemberAccessStrategy { get; set; } = new DefaultMemberAccessStrategy();
/// <summary>
/// Gets or sets the <see cref="IFileProvider"/> used to access files for include and render statements.
/// </summary>
public IFileProvider FileProvider { get; set; } = new NullFileProvider();
/// <summary>
/// Gets or sets the maximum number of steps a script can execute. Leave to 0 for unlimited.
/// </summary>
public int MaxSteps { get; set; }
/// <summary>
/// Gets or sets the <see cref="CultureInfo"/> instance used to render locale values like dates and numbers.
/// </summary>
public CultureInfo CultureInfo { get; set; } = CultureInfo.InvariantCulture;
/// <summary>
/// Gets or sets the value returned by the "now" keyword.
/// </summary>
public Func<DateTimeOffset> Now { get; set; } = static () => DateTimeOffset.Now;
/// <summary>
/// Gets or sets the local time zone used when parsing or creating dates without specific ones.
/// </summary>
public TimeZoneInfo TimeZone { get; set; } = TimeZoneInfo.Local;
/// <summary>
/// Gets or sets the maximum depth of recursions a script can execute. 100 by default.
/// </summary>
public int MaxRecursion { get; set; } = 100;
/// <summary>
/// Gets the collection of filters available in the templates.
/// </summary>
public FilterCollection Filters { get; } = new FilterCollection();
/// <summary>
/// Gets a scope that is available in all the templates.
/// </summary>
public Scope Scope { get; } = new Scope();
/// <summary>
/// Gets the list of value converters.
/// </summary>
public List<Func<object, object>> ValueConverters { get; } = new List<Func<object, object>>();
/// <summary>
/// Gets or sets the delegate to execute when a Capture tag has been evaluated.
/// </summary>
public Func<string, string, ValueTask<string>> Captured { get; set; }
/// <summary>
/// Gets or sets the default trimming rules.
/// </summary>
public TrimmingFlags Trimming { get; set; } = TrimmingFlags.None;
/// <summary>
/// Gets or sets whether trimming is greedy. Default is true. When set to true, all successive blank chars are trimmed.
/// </summary>
public bool Greedy { get; set; } = true;
public TemplateOptions()
{
Filters.WithArrayFilters()
.WithStringFilters()
.WithNumberFilters()
.WithMiscFilters();
}
}
}