1# coding: utf-8
2
3"""
4This module provides a central location for defining default behavior.
5
6Throughout the package, these defaults take effect only when the user
7does not otherwise specify a value.
8
9"""
10
11try:
12    # Python 3.2 adds html.escape() and deprecates cgi.escape().
13    from html import escape
14except ImportError:
15    from cgi import escape
16
17import os
18import sys
19
20from 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#
30DECODE_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.
34STRING_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.
39FILE_ENCODING = sys.getdefaultencoding()
40
41# The delimiters to start with when parsing.
42DELIMITERS = (u'{{', u'}}')
43
44# How to handle missing tags when rendering a template.
45MISSING_TAGS = MissingTags.ignore
46
47# The starting list of directories in which to search for templates when
48# loading a template by file name.
49SEARCH_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#
62TAG_ESCAPE = lambda u: escape(u, quote=True)
63
64# The default template extension, without the leading dot.
65TEMPLATE_EXTENSION = 'mustache'
66