-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathPlugin.csx
More file actions
60 lines (54 loc) · 1.51 KB
/
Plugin.csx
File metadata and controls
60 lines (54 loc) · 1.51 KB
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
using Pretzel.Logic.Templating;
using Pretzel.Logic.Templating.Context;
using System.ComponentModel.Composition;
using System.Collections.Generic;
using System.Linq;
[SiteEngineInfo(Engine="customxmlmd")]
public class Processor : ISiteEngine
{
public string AllowableCustomTags {get; set;}
public void Initialize()
{
}
public bool CanProcess(SiteContext context)
{
var readmePage = context.Posts.Where(p => p.File.ToLower().EndsWith("readme.md")).FirstOrDefault();
if(null == readmePage)
{
//if no readme.md then return false
return false;
}
if(readmePage.Bag.ContainsKey("mergexmlcomments"))
{
Console.WriteLine("about to check 'mergexmlcomments' a bool");
if(!(bool)(readmePage.Bag["mergexmlcomments"]))
{
Console.WriteLine("as boolean 'mergexmlcomments' is false");
//if there is a mergexmlcomments value in the front matter
//but it is false
return false;
}
Console.WriteLine("as boolean 'mergexmlcomments' is true");
AllowableCustomTags = (string)(readmePage.Bag["allowedcustomtags"]);
return true;
}
else
{
Console.WriteLine("Bag doesn't contain 'mergexmlcomments'");
//no mergexmlcomments value
return false;
}
}
public void Process(SiteContext context, bool skipFileOnError = false)
{
Console.WriteLine($@"About to check CanProcess(context) again");
if(CanProcess(context))
{
Console.WriteLine($@"Custom Tag to allow: {AllowableCustomTags}");
}
else
{
Console.WriteLine($@"CanProcess(context) is false this time");
}
}
}