Skip to content

Instantly share code, notes, and snippets.

@oscaruribe
Created February 23, 2016 18:02
Show Gist options
  • Save oscaruribe/b82aa3e1e78a62a707d5 to your computer and use it in GitHub Desktop.
Save oscaruribe/b82aa3e1e78a62a707d5 to your computer and use it in GitHub Desktop.
using System.Collections.Generic;
using System.IO;
using MailDirect.v4.Core.Util;
using Mustache;
namespace Ungapped.Core.Rendering
{
public class UrlEncodeTagDefinition : InlineTagDefinition
{
public UrlEncodeTagDefinition() : base("urlencode")
{
}
protected override IEnumerable<TagParameter> GetParameters()
{
return new [] { new TagParameter("name") { IsRequired = true } };
}
public override void GetText(TextWriter writer, Dictionary<string, object> arguments, Scope context)
{
foreach (var key in arguments.Keys)
{
if (arguments[key] != null)
{
writer.Write(arguments[key].UrlEncoded());
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment