Add support for Wordpress Shortcodes in a .NET application.
- Parsing works in most cases, but more tests need to be added for edge cases.
Install through NuGet:
Install-Package Shortcoder -Pre
Follow steps below to get started.
-
Create a Shortcode class.
public class NowShortcode : Shortcode { public override string Generate(IShortcodeContext context) { return DateTime.Now.ToString(); } }
-
Register the shortcode.
ShortcodeFactory.Provider.Add<NowShortcode>(tag: "now");
-
Parse content using registered shortcodes
var content = "The date and time is: [now]."; var parsedContent = ShortcodeFactory.Parser.Parse(body);
Result:
parsedContent == "The date and time is: 2015-01-01 10:10:00."
See LICENSE