emark


Nameemark JSON
Version 1.0.0 PyPI version JSON
download
home_page
SummaryMarkdown template based HTML and text emails for Django.
upload_time2023-05-23 10:41:46
maintainer
docs_urlNone
author
requires_python>=3.10
license
keywords markdown django email templates html
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django eMark↓

<img alt="emark logo: envelope with markdown stamp" src="https://raw.githubusercontent.com/voiio/emark/main/emark-logo.svg" width="320" height="170" align="right">

Markdown template based HTML and text emails for Django.

* simple email templates with markdown
* support for HTML and text emails
* i18n support
* built-in UTM tracking
* automatic CSS inliner via [premailer](https://github.com/peterbe/premailer/)

[![PyPi Version](https://img.shields.io/pypi/v/emark.svg)](https://pypi.python.org/pypi/emark/)
[![Test Coverage](https://codecov.io/gh/voiio/emark/branch/main/graph/badge.svg)](https://codecov.io/gh/voiio/emark)
[![GitHub License](https://img.shields.io/github/license/voiio/emark)](https://raw.githubusercontent.com/voiio/emark/master/LICENSE)

## Setup

```ShellSession
python3 -m pip install emark
```

```python
# settings.py
INSTALLED_APPS = [
    'emark',
    # ...
]
```

```ShellSession
python3 manage.py migrate
```

## Usage

```markdown
<!-- myapp/my_message.md -->
# Hello World

Hi {{ user.short_name }}!
```

```python
# myapp/emails.py
from emark.message import MarkdownEmail

class MyMessage(MarkdownEmail):
    subject = "Hello World"
    template_name = "myapp/my_message.md"
```

```python
# myapp/views.py
from . import emails

def my_view(request):
    message = emails.MyMessage.to_user(request.user)
    message.send()
```

### Templates

You can use Django's template engine, just like you usually would.
You can use translations, template tags, filters, blocks, etc.

You may also have a base template, that you inherit form in your individual
emails to provide a consistent salutation and farewell.

```markdown
<!-- base.md -->
{% load static i18n %}
{% block salutation %}Hi {{ user.short_name }}!{% endblock %}

{% block content %}{% endblock %}

{% block farewell %}
{% blocktrans trimmed %}
Best regards,
{{ site_admin }}
{% endblocktrans %}
{% endblock %}

{% block footer %}
Legal footer.
{% endblock %}
```

```markdown
<!-- myapp/email.md -->
{% extends "base.md" %}

{% block content %}
This is the content of the email.
{% endblock %}
```

### Context

The context is passed to the template as a dictionary. Furthermore, you may
override the `get_context_data` method to add additional context variables.

```python
# myapp/emails.py
from emark.message import MarkdownEmail

class MyMessage(MarkdownEmail):
    subject = "Hello World"
    template_name = "myapp/email.md"

    def get_context_data(self):
        context = super().get_context_data()
        context["my_variable"] = "Hello World"
        return context
```

### Tracking

Every `MarkdownEmail` subclass comes with automatic UTM tracking.
UTM parameters are added to all links in the email. Existing UTM params on link
that have been explicitly set, are not overridden. The default parameters are:

* `utm_source`: `website`
* `utm_medium`: `email`
* `utm_campaign`: `{{ EMAIL_CLASS_NAME }}`

The global UTM parameters can be overridden via the `EMARK_UTM_PARAMS` setting,
which is a dictionary of parameters:

```python
# settings.py
EMARK_UTM_PARAMS = {
    "utm_source": "website",  # default
    "utm_medium": "email",  # default
}
```

You may also change the UTM parameters by overriding the `get_utm_params`
or passing a `utm_params` dictionary to class constructor.

```python
# myapp/emails.py
from emark.message import MarkdownEmail


class MyMessage(MarkdownEmail):
  subject = "Hello World"
  template_name = "myapp/email.md"

  # override the parameters for this email class
  def get_utm_params(self):
    return {
      "utm_source": "myapp",
      "utm_medium": "email",
      "utm_campaign": "my-campaign",
    }


# or alternatively during instantiation
MyMessage(utm_params={"utm_campaign": "my-other-campaign"}).send()
```

## Credits

- Django eMark uses modified version of [Responsive HTML Email Template](https://github.com/leemunroe/responsive-html-email-template/) as a base template
- For CSS inlining, Django eMark uses [premailer](https://github.com/peterbe/premailer/)


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "emark",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "Markdown,Django,email,templates,HTML",
    "author": "",
    "author_email": "Rust Saiargaliev <fly.amureki@gmail.com>, Johannes Maron <johannes@maron.family>, Mostafa Mohamed <mostafa.anm91@gmail.com>, Jacqueline Kraus <jacquelinekraus1992@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/28/42/2f26bf65f7ca2840d6b42342769c0decf833d9a7d5293d1ecadd2c3a9e60/emark-1.0.0.tar.gz",
    "platform": null,
    "description": "# Django eMark\u2193\n\n<img alt=\"emark logo: envelope with markdown stamp\" src=\"https://raw.githubusercontent.com/voiio/emark/main/emark-logo.svg\" width=\"320\" height=\"170\" align=\"right\">\n\nMarkdown template based HTML and text emails for Django.\n\n* simple email templates with markdown\n* support for HTML and text emails\n* i18n support\n* built-in UTM tracking\n* automatic CSS inliner via [premailer](https://github.com/peterbe/premailer/)\n\n[![PyPi Version](https://img.shields.io/pypi/v/emark.svg)](https://pypi.python.org/pypi/emark/)\n[![Test Coverage](https://codecov.io/gh/voiio/emark/branch/main/graph/badge.svg)](https://codecov.io/gh/voiio/emark)\n[![GitHub License](https://img.shields.io/github/license/voiio/emark)](https://raw.githubusercontent.com/voiio/emark/master/LICENSE)\n\n## Setup\n\n```ShellSession\npython3 -m pip install emark\n```\n\n```python\n# settings.py\nINSTALLED_APPS = [\n    'emark',\n    # ...\n]\n```\n\n```ShellSession\npython3 manage.py migrate\n```\n\n## Usage\n\n```markdown\n<!-- myapp/my_message.md -->\n# Hello World\n\nHi {{ user.short_name }}!\n```\n\n```python\n# myapp/emails.py\nfrom emark.message import MarkdownEmail\n\nclass MyMessage(MarkdownEmail):\n    subject = \"Hello World\"\n    template_name = \"myapp/my_message.md\"\n```\n\n```python\n# myapp/views.py\nfrom . import emails\n\ndef my_view(request):\n    message = emails.MyMessage.to_user(request.user)\n    message.send()\n```\n\n### Templates\n\nYou can use Django's template engine, just like you usually would.\nYou can use translations, template tags, filters, blocks, etc.\n\nYou may also have a base template, that you inherit form in your individual\nemails to provide a consistent salutation and farewell.\n\n```markdown\n<!-- base.md -->\n{% load static i18n %}\n{% block salutation %}Hi {{ user.short_name }}!{% endblock %}\n\n{% block content %}{% endblock %}\n\n{% block farewell %}\n{% blocktrans trimmed %}\nBest regards,\n{{ site_admin }}\n{% endblocktrans %}\n{% endblock %}\n\n{% block footer %}\nLegal footer.\n{% endblock %}\n```\n\n```markdown\n<!-- myapp/email.md -->\n{% extends \"base.md\" %}\n\n{% block content %}\nThis is the content of the email.\n{% endblock %}\n```\n\n### Context\n\nThe context is passed to the template as a dictionary. Furthermore, you may\noverride the `get_context_data` method to add additional context variables.\n\n```python\n# myapp/emails.py\nfrom emark.message import MarkdownEmail\n\nclass MyMessage(MarkdownEmail):\n    subject = \"Hello World\"\n    template_name = \"myapp/email.md\"\n\n    def get_context_data(self):\n        context = super().get_context_data()\n        context[\"my_variable\"] = \"Hello World\"\n        return context\n```\n\n### Tracking\n\nEvery `MarkdownEmail` subclass comes with automatic UTM tracking.\nUTM parameters are added to all links in the email. Existing UTM params on link\nthat have been explicitly set, are not overridden. The default parameters are:\n\n* `utm_source`: `website`\n* `utm_medium`: `email`\n* `utm_campaign`: `{{ EMAIL_CLASS_NAME }}`\n\nThe global UTM parameters can be overridden via the `EMARK_UTM_PARAMS` setting,\nwhich is a dictionary of parameters:\n\n```python\n# settings.py\nEMARK_UTM_PARAMS = {\n    \"utm_source\": \"website\",  # default\n    \"utm_medium\": \"email\",  # default\n}\n```\n\nYou may also change the UTM parameters by overriding the `get_utm_params`\nor passing a `utm_params` dictionary to class constructor.\n\n```python\n# myapp/emails.py\nfrom emark.message import MarkdownEmail\n\n\nclass MyMessage(MarkdownEmail):\n  subject = \"Hello World\"\n  template_name = \"myapp/email.md\"\n\n  # override the parameters for this email class\n  def get_utm_params(self):\n    return {\n      \"utm_source\": \"myapp\",\n      \"utm_medium\": \"email\",\n      \"utm_campaign\": \"my-campaign\",\n    }\n\n\n# or alternatively during instantiation\nMyMessage(utm_params={\"utm_campaign\": \"my-other-campaign\"}).send()\n```\n\n## Credits\n\n- Django eMark uses modified version of [Responsive HTML Email Template](https://github.com/leemunroe/responsive-html-email-template/) as a base template\n- For CSS inlining, Django eMark uses [premailer](https://github.com/peterbe/premailer/)\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Markdown template based HTML and text emails for Django.",
    "version": "1.0.0",
    "project_urls": {
        "Changelog": "https://github.com/voiio/emark/releases",
        "Project-URL": "https://github.com/voiio/emark"
    },
    "split_keywords": [
        "markdown",
        "django",
        "email",
        "templates",
        "html"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "79ae890d66e642f83bcd7061dacd25728069bcd0ce4c42b75f246a159c688fd9",
                "md5": "819bdb12f899bbb592b35bc637f9c5fd",
                "sha256": "b0192e4b9aef4746ea45f52703d50b438f764b1fd80e4ec2b0e81b40ba5b245d"
            },
            "downloads": -1,
            "filename": "emark-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "819bdb12f899bbb592b35bc637f9c5fd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 11928,
            "upload_time": "2023-05-23T10:41:45",
            "upload_time_iso_8601": "2023-05-23T10:41:45.198437Z",
            "url": "https://files.pythonhosted.org/packages/79/ae/890d66e642f83bcd7061dacd25728069bcd0ce4c42b75f246a159c688fd9/emark-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28422f26bf65f7ca2840d6b42342769c0decf833d9a7d5293d1ecadd2c3a9e60",
                "md5": "872b51f7514991beb226e90be9dd54fd",
                "sha256": "f4f752909efcccd9ec94f2edd2bc62807e5ab7037d49dd55b1f746793ae24d3c"
            },
            "downloads": -1,
            "filename": "emark-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "872b51f7514991beb226e90be9dd54fd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 11680,
            "upload_time": "2023-05-23T10:41:46",
            "upload_time_iso_8601": "2023-05-23T10:41:46.877545Z",
            "url": "https://files.pythonhosted.org/packages/28/42/2f26bf65f7ca2840d6b42342769c0decf833d9a7d5293d1ecadd2c3a9e60/emark-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-23 10:41:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "voiio",
    "github_project": "emark",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "emark"
}
        
Elapsed time: 0.17761s