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
|
|
|
|
|
|
|
|
|
public class UrlEncodeTagDefinition : ContentTagDefinition {
|
|
|
|
|
public UrlEncodeTagDefinition()
|
|
|
|
|
: base("urlencode") {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2021-12-17 10:21:14 +00:00
|
|
|
|
}
|
2016-09-19 10:40:43 +00:00
|
|
|
|
|
|
|
|
|
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.UrlEncode(writer.ToString());
|
2016-09-19 10:40:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|