summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pystache/defaults.py18
-rw-r--r--pystache/loader.py9
-rw-r--r--pystache/locator.py10
-rw-r--r--pystache/renderer.py9
4 files changed, 32 insertions, 14 deletions
diff --git a/pystache/defaults.py b/pystache/defaults.py
new file mode 100644
index 0000000..b9156d6
--- /dev/null
+++ b/pystache/defaults.py
@@ -0,0 +1,18 @@
+# coding: utf-8
+
+"""
+This module provides a central location for defining default behavior.
+
+"""
+
+# How to handle encoding errors when decoding strings from str to unicode.
+#
+# This value is passed as the "errors" argument to Python's built-in
+# unicode() function:
+#
+# http://docs.python.org/library/functions.html#unicode
+#
+DECODE_ERRORS = 'strict'
+
+# The default template extension.
+TEMPLATE_EXTENSION = 'mustache'
diff --git a/pystache/loader.py b/pystache/loader.py
index 7c56929..2c94860 100644
--- a/pystache/loader.py
+++ b/pystache/loader.py
@@ -10,8 +10,7 @@ from __future__ import with_statement
import os
import sys
-
-DEFAULT_DECODE_ERRORS = 'strict'
+from . import defaults
class Loader(object):
@@ -29,12 +28,12 @@ class Loader(object):
sys.getdefaultencoding().
decode_errors: the string to pass as the errors argument to the
- built-in function unicode() when converting file contents to
- unicode. Defaults to "strict".
+ built-in function unicode() when converting str strings to
+ unicode. Defaults to the package default.
"""
if decode_errors is None:
- decode_errors = DEFAULT_DECODE_ERRORS
+ decode_errors = defaults.DECODE_ERRORS
if encoding is None:
encoding = sys.getdefaultencoding()
diff --git a/pystache/locator.py b/pystache/locator.py
index ebcbd25..6bc7d64 100644
--- a/pystache/locator.py
+++ b/pystache/locator.py
@@ -9,8 +9,7 @@ import os
import re
import sys
-
-DEFAULT_EXTENSION = 'mustache'
+from . import defaults
class Locator(object):
@@ -21,12 +20,13 @@ class Locator(object):
Arguments:
- extension: the template file extension. Defaults to "mustache".
- Pass False for no extension (i.e. extensionless template files).
+ extension: the template file extension. Pass False for no
+ extension (i.e. to use extensionless template files).
+ Defaults to the package default.
"""
if extension is None:
- extension = DEFAULT_EXTENSION
+ extension = defaults.TEMPLATE_EXTENSION
self.template_extension = extension
diff --git a/pystache/renderer.py b/pystache/renderer.py
index 92ac7ac..ece6d0e 100644
--- a/pystache/renderer.py
+++ b/pystache/renderer.py
@@ -9,10 +9,10 @@ import cgi
import os
import sys
+from . import defaults
from .context import Context
# TODO: remove this alias.
from .loader import Loader as Reader
-from .locator import DEFAULT_EXTENSION
from .locator import Locator
from .renderengine import RenderEngine
@@ -96,8 +96,9 @@ class Renderer(object):
current working directory. If given a string, the string is
interpreted as a single directory.
- file_extension: the template file extension. Defaults to "mustache".
- Pass False for no extension (i.e. for extensionless files).
+ file_extension: the template file extension. Pass False for no
+ extension (i.e. to use extensionless template files).
+ Defaults to the package default.
"""
if default_encoding is None:
@@ -111,7 +112,7 @@ class Renderer(object):
file_encoding = default_encoding
if file_extension is None:
- file_extension = DEFAULT_EXTENSION
+ file_extension = defaults.TEMPLATE_EXTENSION
if search_dirs is None:
search_dirs = os.curdir # i.e. "."