Skip to content

Instantly share code, notes, and snippets.

@anaisbetts
Created October 14, 2015 20:32
Show Gist options
  • Select an option

  • Save anaisbetts/4b8bce247ce8ed6016e5 to your computer and use it in GitHub Desktop.

Select an option

Save anaisbetts/4b8bce247ce8ed6016e5 to your computer and use it in GitHub Desktop.
It's like a crappy version of mustache
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
namespace Squirrel.Update
{
public static class CopStache
{
public static string Render(string template, Dictionary<string, string> identifiers)
{
var buf = new StringBuilder();
foreach (var line in template.Split('\n')) {
identifiers["RandomGuid"] = (new Guid()).ToString();
foreach (var key in identifiers.Keys) {
buf.Replace("{{" + key + "}}", SecurityElement.Escape(identifiers[key]));
}
buf.AppendLine(line);
}
return buf.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment