Commits

Andriy Kornatskyy  committed 91d0008

Added known variable filters, so it can translate shortcuts to full names.

  • Participants
  • Parent commits 8cd6c7a

Comments (0)

Files changed (1)

File src/wheezy/template/ext/core.py

 
 import re
 
+from wheezy.template.comp import PY3
 from wheezy.template.utils import find_all_balanced
 
 
 reserved_tokens = ['require', '#', 'include']
 all_tokens = end_tokens + compound_tokens + reserved_tokens
 out_tokens = ['markup', 'var', 'include']
-
+known_var_filters = {
+        's': PY3 and 'str' or 'unicode'
+}
 
 # region: preprocessors
 
             var, var_filters = value
             if var_filters:
                 for f in reversed(var_filters):
-                    var = f + '(' + var + ')'
+                    var = known_var_filters.get(f, f) + '(' + var + ')'
             builder.add(lineno, 'w(' + var + ')')
         elif value:
             builder.add(lineno, 'w(' + value + ')')
     """
 
     lexer_rules = {
-            100: (re.compile(r'@((%s).*?(?<!\\))\n'
+            100: (re.compile(r'@((%s).*?(?<!\\))\n|$'
                     % '|'.join(all_tokens), re.S),
                 stmt_token),
             200: (re.compile(r'@(\w+(\.\w+)*)'),