wndrr-perso - Wndrr.Mjml.CSharp 0.1.2
A C# wrapper for the MJML framework
PM> Install-Package Wndrr.Mjml.CSharp -Version 0.1.2 -Source https://www.myget.org/F/wndrr-perso/api/v3/index.json
> nuget.exe install Wndrr.Mjml.CSharp -Version 0.1.2 -Source https://www.myget.org/F/wndrr-perso/api/v3/index.json
> dotnet add package Wndrr.Mjml.CSharp --version 0.1.2 --source https://www.myget.org/F/wndrr-perso/api/v3/index.json
source https://www.myget.org/F/wndrr-perso/api/v3/index.json
nuget Wndrr.Mjml.CSharp ~> 0.1.2
Copy to clipboard
> choco install Wndrr.Mjml.CSharp --version 0.1.2 --source https://www.myget.org/F/wndrr-perso/api/v2
Import-Module PowerShellGet
Register-PSRepository -Name "wndrr-perso" -SourceLocation "https://www.myget.org/F/wndrr-perso/api/v2"
Install-Module -Name "Wndrr.Mjml.CSharp" -RequiredVersion "0.1.2" -Repository "wndrr-perso"
Copy to clipboard
Browse the sources in this package using Visual Studio or WinDbg by configuring the following legacy symbol server URL: https://www.myget.org/F/wndrr-perso/symbols/
Mjml-CSharp
A C#.NET Wrapper for the Mjml framework
The list of currently planned features and their status can be found on the project's dashboard.
For feature requests and troubleshooting you can open an issue.
Getting Started
This page will give you instructions to install the library, and the minimal code to get started using it.
Installing
note: This library has only been tested with a global installation of NodeJs v13. Aparently, it doesn't work with node v10 or v12 (as per the issue #12
The latest release can downloaded from NuGet.org.
You can install the package using the VisualStudio NuGet integration by searching for the Wndrr.Mjml.CSharp package.
To work, the Mjml wrapper requires you to have NodeJs installed and the Mjml NPM package installed in your dependencies or devDependencies section.
Example package.json
"devDependencies": {
"mjml": "^4.6.2"
}
Minimal code
Initialization
You will need to tell the library where to find node, npm and where to write temporary files. This can be done as follow, before any call to Render() is made :
Mjml.PathRepository.NodePath = @"C:\Program Files\nodejs\node.exe";
Mjml.PathRepository.TmpPath = Path.GetTempPath();
The simple way
Once the paths are set, you can render your MJML templates simply by calling Mjml.Render(/* mjml */)
var mjmlTemplate = "<mjml><mj-body><mj-container><mj-section><mj-column><mj-image width="100" src="/assets/img/logo-small.png"></mj-image><mj-divider border-color="#F45E43"></mj-divider><mj-text font-size="20px" color="#F45E43" font-family="helvetica">Hello World</mj-text></mj-column></mj-section></mj-container></mj-body></mjml>";
var outputHtml = Mjml.Render(mjmlTemplate);
The Render method will return a string containing the HTML compiled from the input MJML code.
Deployment
Be sure to use apropriate paths for the target server. This should be improved at some point. You can refer to the related issue
Built With
Mjml framework - Responsive email templating framework engine thingy thingy (these guys are cool af)
Contributing
If you are willing to improve this project, read the contributing page.
Versioning
Versioning should be following the SemVer v2.0.0 rules quite well (actually ... kind-of-maybe-somewhat)
You can find the released versions on the tags page
The latest in-dev versions can be found on the MyGet repo
Authors
- Mathieu Viales Aka. Wndrr
License
This project is licensed under the MIT License - see the license file for details
Acknowledgments
- Thanks to the guys that made Node.exe (whoever they are)
- Kinda thanks to the makers of npm even tho it's a pain to use it programatically
- Thanks to the guys that made the MJML framework, give them a hi on their slack
- Special thanks to Iryusa and Dalefish for the help and directions
- Super Thanks to Iryusa for the code sample
Test release
- .NETFramework 4.5: 4.5.0.0
| Assembly | Assembly hash | Match |
|---|---|---|
| /lib/net45/system.management.automation.dll | 04daf9cbdbdf488b9df433f386e5ca311 | |
| /lib/net45/wndrr.mjml.csharp.dll | 5cb1a9c88b5f488d960abe46434cff141 |
OwnersWndrr |
AuthorsWndrr |
Project URLhttps://github.com/Wndrr/Mjml-CSharp |
LicenseMIT |
TagsC#, Mjml |
Info350 total downloads |
| 50 downloads for version 0.1.2 |
| Download (11.31 MB) |
| Download legacy symbols (11.32 MB) |
| Found on the current feed only |
Package history
| Version | Size | Last updated | Downloads | Mirrored? | |||
|---|---|---|---|---|---|---|---|
|
|
1.0.2 | 19.45 KB | Mon, 09 Oct 2017 14:10:23 GMT | 41 |
|
||
|
|
1.0.1 | 19.42 KB | Mon, 09 Oct 2017 12:00:25 GMT | 55 |
|
||
|
|
1.0.0 | 19.42 KB | Sun, 08 Oct 2017 16:15:12 GMT | 52 |
|
||
|
|
0.1.3 | 11.31 MB | Sun, 01 Oct 2017 20:55:58 GMT | 54 |
|
||
|
|
0.1.2 | 11.31 MB | Sun, 01 Oct 2017 18:00:52 GMT | 50 |
|
||
|
|
0.1.1 | 11.31 MB | Sun, 01 Oct 2017 16:48:14 GMT | 45 |
|
||
|
|
0.1.0 | 8.75 MB | Wed, 27 Sep 2017 18:28:31 GMT | 53 |
|