From: Armin Ronacher Date: Thu, 5 Apr 2007 17:15:11 +0000 (+0200) Subject: [svn] jinja webpage without annyoing .html suffixes now X-Git-Tag: 2.0rc1~372 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1f1823c6fe06e2d06b2d17a795458b13389eb817;p=jinja2.git [svn] jinja webpage without annyoing .html suffixes now --HG-- branch : trunk --- diff --git a/docs/generate.py b/docs/generate.py index 9ae42f4..76e027c 100755 --- a/docs/generate.py +++ b/docs/generate.py @@ -258,7 +258,8 @@ def handle_file(filename, fp, dst, preproc): now = datetime.now() title = os.path.basename(filename)[:-4] content = fp.read() - parts = generate_documentation(content, (lambda x: './%s.html' % x)) + suffix = not preproc and '.html' or '' + parts = generate_documentation(content, (lambda x: './%s%s' % (x, suffix))) result = file(os.path.join(dst, title + '.html'), 'w') c = dict(parts) c['style'] = PYGMENTS_FORMATTER.get_style_defs('.syntax') diff --git a/jinja/datastructure.py b/jinja/datastructure.py index 7ccd64f..85186d2 100644 --- a/jinja/datastructure.py +++ b/jinja/datastructure.py @@ -16,9 +16,6 @@ except NameError: from sets import Set as set from jinja.exceptions import TemplateSyntaxError, TemplateRuntimeError -from cgi import escape - -_known_safe_types = set([int, long, float]) def contextcallable(f): @@ -159,6 +156,9 @@ class Deferred(object): class Markup(unicode): """ Compatibility for Pylons and probably some other frameworks. + + It's only used in Jinja environments with `auto_escape` set + to true. """ def __html__(self): diff --git a/jinja/environment.py b/jinja/environment.py index ed75a06..b390c01 100644 --- a/jinja/environment.py +++ b/jinja/environment.py @@ -13,7 +13,7 @@ from jinja.lexer import Lexer from jinja.parser import Parser from jinja.loaders import LoaderWrapper from jinja.datastructure import Undefined, Markup, Context, FakeTranslator -from jinja.utils import escape, collect_translations, get_attribute +from jinja.utils import collect_translations, get_attribute from jinja.exceptions import FilterNotFound, TestNotFound, \ SecurityException, TemplateSyntaxError, TemplateRuntimeError from jinja.defaults import DEFAULT_FILTERS, DEFAULT_TESTS, DEFAULT_NAMESPACE diff --git a/jinja/filters.py b/jinja/filters.py index 971d99b..f54aaa1 100644 --- a/jinja/filters.py +++ b/jinja/filters.py @@ -105,12 +105,15 @@ def do_escape(attribute=False): This method will have no effect it the value is already escaped. """ + #: because filters are cached we can make a local alias to + #: speed things up a bit + e = escape def wrapped(env, context, s): if isinstance(s, TemplateData): return s elif hasattr(s, '__html__'): return s.__html__() - return escape(env.to_unicode(s), attribute) + return e(env.to_unicode(s), attribute) return wrapped diff --git a/jinja/lexer.py b/jinja/lexer.py index ec5052c..4d5986a 100644 --- a/jinja/lexer.py +++ b/jinja/lexer.py @@ -50,7 +50,7 @@ operator_re = re.compile('(%s)' % '|'.join([ '[', ']', '(', ')', '{', '}', # attribute access and comparison / logical operators '.', ':', ',', '|', '==', '<', '>', '<=', '>=', '!=', '=', - ur'or\b', ur'and\b', ur'not\b', ur'in\b', ur'is' + ur'or\b', ur'and\b', ur'not\b', ur'in\b', ur'is\b' ]])) # set of used keywords