Created
April 9, 2013 12:44
-
-
Save thecodejunkie/5345420 to your computer and use it in GitHub Desktop.
SSVE gist matcher
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
public class GistSuperSimpleViewEngineExtension : ISuperSimpleViewEngineExtension | |
{ | |
private readonly Regex regex = new Regex(@"(?:@gist\[(?<id>[a-z01-9]*)\])", RegexOptions.Compiled | RegexOptions.IgnoreCase); | |
private const string GistTemplate = "<script src='https://gist.github.com/{0}.js'></script>"; | |
public string Invoke(string content, dynamic model, IViewEngineHost host) | |
{ | |
return regex.Replace(content, match => (match.Groups["id"].Success) ? string.Format(GistTemplate, match.Groups["id"].Value) : string.Empty); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment