-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
36 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ Development Lead | |
Contributors | ||
------------ | ||
|
||
None yet. Why not be the first? | ||
* Christian Carter <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
------------- | ||
|