From 122f4503edc7569ef47f7527d5d30619d4b05d30 Mon Sep 17 00:00:00 2001 From: Alex Koutmos Date: Sun, 17 Apr 2022 01:06:18 -0400 Subject: [PATCH] 0.3.0 release --- CHANGELOG.md | 2 +- README.md | 4 +-- lib/mjml_eex/layout.ex | 55 +++++++++++++++++++++++++++++++++++++----- mix.exs | 2 +- 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7255a3c..1057fe1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [0.3.0] - 2021-04-18 +## [0.3.0] - 2021-04-17 ### Added diff --git a/README.md b/README.md index b1de1ae..50e06d1 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ dependencies in `mix.exs`: ```elixir def deps do [ - {:mjml_eex, "~> 0.2.0"} + {:mjml_eex, "~> 0.3.0"} ] end ``` @@ -78,7 +78,7 @@ Checkout my [GitHub Sponsorship page](https://github.com/sponsors/akoutmos) if y ### Basic Usage -Add `{:mjml_eex, "~> 0.2.0"}` to your `mix.exs` file and run `mix deps.get`. After you have that in place, you +Add `{:mjml_eex, "~> 0.3.0"}` to your `mix.exs` file and run `mix deps.get`. After you have that in place, you can go ahead and create a template module like so: ```elixir diff --git a/lib/mjml_eex/layout.ex b/lib/mjml_eex/layout.ex index d7e49d9..cf87b51 100644 --- a/lib/mjml_eex/layout.ex +++ b/lib/mjml_eex/layout.ex @@ -1,13 +1,56 @@ defmodule MjmlEEx.Layout do @moduledoc """ - This module allows you to define a MJML layouts so that you - can create reusable email skeletons. - """ + This module allows you to define an MJML layout so that you + can create reusable email skeletons. To use layouts with your + MJML emails, create a layout template that contains an + `<%= @inner_content %>` expression in it like so: + + ```html + + + Say hello to card + + + + + + + + + <%= @inner_content %> + + ``` + + You can also include additional assigns like `@padding` in this + example. Just make sure that you provide that assign when you + are rendering the final template. With that in place, you can + define a layout module like so + + ```elixir + defmodule BaseLayout do + use MjmlEEx.Layout, mjml_layout: "base_layout.mjml.eex" + end + ``` + + And then use it in conjunction with your templates like so: + + ```elixir + defmodule MyTemplate do + use MjmlEEx, + mjml_template: "my_template.mjml.eex", + layout: BaseLayout + end + ``` + + Then in your template, all you need to provide are the portions that + you need to complete the layout: - @doc """ - Returns the MJML markup for the layout as a string. + ```html + + ... + + ``` """ - @callback render(opts :: keyword()) :: String.t() defmacro __using__(opts) do mjml_layout = diff --git a/mix.exs b/mix.exs index a620fb2..142e7b8 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule MjmlEEx.MixProject do def project do [ app: :mjml_eex, - version: "0.2.0", + version: "0.3.0", elixir: ">= 1.11.0", elixirc_paths: elixirc_paths(Mix.env()), name: "MJML EEx",