forked from SparkDevNetwork/Rock
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDocument.cs
73 lines (68 loc) · 1.83 KB
/
Document.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
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using DotLiquid.Exceptions;
namespace DotLiquid
{
public class Document : Block
{
/// <summary>
/// We don't need markup to open this block
/// </summary>
/// <param name="tagName"></param>
/// <param name="markup"></param>
/// <param name="tokens"></param>
public override void Initialize(string tagName, string markup, List<string> tokens)
{
var initialTokens = tokens.ToArray();
try
{
Parse( tokens );
}
catch (SyntaxException se)
{
var remainingTokens = tokens.ToArray();
var processedTokens = initialTokens.Take( initialTokens.Length - remainingTokens.Length ).ToList();
StringBuilder stringBuilder = new StringBuilder();
foreach (var token in processedTokens)
{
stringBuilder.Append( StandardFilters.Escape( token ) );
}
se.LavaStackTrace = stringBuilder.ToString() + " ^...";
throw;
}
}
/// <summary>
/// There isn't a real delimiter
/// </summary>
protected override string BlockDelimiter
{
get { return string.Empty; }
}
/// <summary>
/// Document blocks don't need to be terminated since they are not actually opened
/// </summary>
protected override void AssertMissingDelimitation()
{
}
/// <summary>
/// This is used to handle the new known/valid control exceptions in Liquid.
/// </summary>
/// <param name="context"></param>
/// <param name="result"></param>
public override void Render(Context context, TextWriter result)
{
try
{
base.Render(context, result);
}
catch (BreakInterrupt)
{
}
catch (ContinueInterrupt)
{
}
}
}
}