Created
October 14, 2015 20:32
-
-
Save anaisbetts/4b8bce247ce8ed6016e5 to your computer and use it in GitHub Desktop.
It's like a crappy version of mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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