MustacheSharp/MustacheSharp/UrlDecodeTagDefinition.cs

29 lines
988 B
C#
Raw Normal View History

2021-12-17 10:21:14 +00:00
using System.Collections.Generic;
2016-09-19 10:40:43 +00:00
using System.IO;
2021-12-17 10:21:14 +00:00
namespace Mustache
{
2016-09-19 10:40:43 +00:00
class UrlDecodeTagDefinition: ContentTagDefinition {
public UrlDecodeTagDefinition()
: base("urldecode") {
}
public override IEnumerable<NestedContext> GetChildContext(TextWriter writer, Scope keyScope, Dictionary<string, object> arguments, Scope contextScope) {
NestedContext context = new NestedContext() {
KeyScope = keyScope,
Writer = new StringWriter(),
WriterNeedsConsidated = true,
};
yield return context;
}
public override IEnumerable<TagParameter> GetChildContextParameters() {
return new TagParameter[] { new TagParameter("collection") };
}
public override string ConsolidateWriter(TextWriter writer, Dictionary<string, object> arguments) {
2021-12-17 10:21:14 +00:00
return System.Net.WebUtility.UrlDecode(writer.ToString());
2016-09-19 10:40:43 +00:00
}
}
}