Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sfdcarter committed Dec 24, 2018
1 parent 827d2c7 commit e6e4375
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ develop-eggs
.installed.cfg
lib
lib64
venv

# Installer logs
pip-log.txt
Expand All @@ -27,21 +28,25 @@ pip-log.txt
.tox
nosetests.xml
htmlcov
.pytest_cache

# Translations
*.mo

# Mr Developer
# IDEs and projects
.mr.developer.cfg
.project
.pydevproject

# Pycharm/Intellij
.idea
.vscode
.python-version

# Complexity
output/*.html
output/*/index.html

# Sphinx
docs/_build

# Annoyances
**/.DS_Store
2 changes: 1 addition & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Development Lead
Contributors
------------

None yet. Why not be the first?
* Christian Carter <[email protected]>
35 changes: 27 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,41 @@ SFDO Template Helpers

A set of Django helpers and utils used by sfdo-template projects.

Documentation
-------------

The full documentation is at https://sfdo-template-helpers.readthedocs.io.

Quickstart
----------

Install SFDO Template Helpers::
Install the current version of SFDO Template Helpers::

pip install -e git+https://github.com/SFDO-Tooling/[email protected]#egg=sfdo_template_helpers

pip install sfdo-template-helpers
Or install the development HEAD::

pip install -e git+https://github.com/SFDO-Tooling/sfdo-template-helpers.git@master#egg=sfdo_template_helpers

`sfdo-template-helpers` is not distributed on PyPI.

Features
--------

* TODO
* MarkdownField - A Django-ORM TextField that stores Markdown formatted text and makes it available as rendered (and properly bleached/whitelisted) HTML.

Documentation
-------------

MarkdownField
'''''''''''''

You can use MarkdownField like an ordinary TextField::

class Product(models.Model):
description = MarkdownField(max_length=2000, null=True, blank=True, help_text='Displayed on the product summary.')

The field does no validation that it is indeed Markdown formatted text, but instead adds a lazy property to the model instance, which will render the text as HTML. The rendered HTML has been ``mark_safe``'d for Django templates.

It has one additional kwarg, ``property_suffix`` that defaults to ``_html``. This is the ... suffix of the property that will be added to your model. Our earlier field would be rendered at ``product.description_html``.

Rendering is safe by default and limited to a SFDC ProdSec reviewed list of properties and attributes. To override what HTML is whitelisted, subclass MarkdownField and override ``markdown_tags`` and ``markdown_attrs``. WARNING: the output of the html property will *still* be a SafeString.


Running Tests
-------------
Expand Down

0 comments on commit e6e4375

Please sign in to comment.