OLD | NEW |
(Empty) | |
| 1 # coding: utf-8 |
| 2 |
| 3 """ |
| 4 This module provides a central location for defining default behavior. |
| 5 |
| 6 Throughout the package, these defaults take effect only when the user |
| 7 does not otherwise specify a value. |
| 8 |
| 9 """ |
| 10 |
| 11 try: |
| 12 # Python 3.2 adds html.escape() and deprecates cgi.escape(). |
| 13 from html import escape |
| 14 except ImportError: |
| 15 from cgi import escape |
| 16 |
| 17 import os |
| 18 import sys |
| 19 |
| 20 from pystache.common import MissingTags |
| 21 |
| 22 |
| 23 # How to handle encoding errors when decoding strings from str to unicode. |
| 24 # |
| 25 # This value is passed as the "errors" argument to Python's built-in |
| 26 # unicode() function: |
| 27 # |
| 28 # http://docs.python.org/library/functions.html#unicode |
| 29 # |
| 30 DECODE_ERRORS = 'strict' |
| 31 |
| 32 # The name of the encoding to use when converting to unicode any strings of |
| 33 # type str encountered during the rendering process. |
| 34 STRING_ENCODING = sys.getdefaultencoding() |
| 35 |
| 36 # The name of the encoding to use when converting file contents to unicode. |
| 37 # This default takes precedence over the STRING_ENCODING default for |
| 38 # strings that arise from files. |
| 39 FILE_ENCODING = sys.getdefaultencoding() |
| 40 |
| 41 # The delimiters to start with when parsing. |
| 42 DELIMITERS = (u'{{', u'}}') |
| 43 |
| 44 # How to handle missing tags when rendering a template. |
| 45 MISSING_TAGS = MissingTags.ignore |
| 46 |
| 47 # The starting list of directories in which to search for templates when |
| 48 # loading a template by file name. |
| 49 SEARCH_DIRS = [os.curdir] # i.e. ['.'] |
| 50 |
| 51 # The escape function to apply to strings that require escaping when |
| 52 # rendering templates (e.g. for tags enclosed in double braces). |
| 53 # Only unicode strings will be passed to this function. |
| 54 # |
| 55 # The quote=True argument causes double but not single quotes to be escaped |
| 56 # in Python 3.1 and earlier, and both double and single quotes to be |
| 57 # escaped in Python 3.2 and later: |
| 58 # |
| 59 # http://docs.python.org/library/cgi.html#cgi.escape |
| 60 # http://docs.python.org/dev/library/html.html#html.escape |
| 61 # |
| 62 TAG_ESCAPE = lambda u: escape(u, quote=True) |
| 63 |
| 64 # The default template extension, without the leading dot. |
| 65 TEMPLATE_EXTENSION = 'mustache' |
OLD | NEW |