Show More
@@ -603,6 +603,7 b' class engine(object):' | |||||
603 | self._resources = resources |
|
603 | self._resources = resources | |
604 | self._aliasmap = _aliasrules.buildmap(aliases) |
|
604 | self._aliasmap = _aliasrules.buildmap(aliases) | |
605 | self._cache = {} # key: (func, data) |
|
605 | self._cache = {} # key: (func, data) | |
|
606 | self._tmplcache = {} # literal template: (func, data) | |||
606 |
|
607 | |||
607 | def overlaymap(self, origmapping, newmapping): |
|
608 | def overlaymap(self, origmapping, newmapping): | |
608 | """Create combined mapping from the original mapping and partial |
|
609 | """Create combined mapping from the original mapping and partial | |
@@ -659,6 +660,13 b' class engine(object):' | |||||
659 | raise |
|
660 | raise | |
660 | return self._cache[t] |
|
661 | return self._cache[t] | |
661 |
|
662 | |||
|
663 | def _parse(self, tmpl): | |||
|
664 | """Parse and cache a literal template""" | |||
|
665 | if tmpl not in self._tmplcache: | |||
|
666 | x = parse(tmpl) | |||
|
667 | self._tmplcache[tmpl] = compileexp(x, self, methods) | |||
|
668 | return self._tmplcache[tmpl] | |||
|
669 | ||||
662 | def preload(self, t): |
|
670 | def preload(self, t): | |
663 | """Load, parse, and cache the specified template if available""" |
|
671 | """Load, parse, and cache the specified template if available""" | |
664 | try: |
|
672 | try: | |
@@ -672,6 +680,18 b' class engine(object):' | |||||
672 | mapping contains added elements for use during expansion. Is a |
|
680 | mapping contains added elements for use during expansion. Is a | |
673 | generator.''' |
|
681 | generator.''' | |
674 | func, data = self._load(t) |
|
682 | func, data = self._load(t) | |
|
683 | return self._expand(func, data, mapping) | |||
|
684 | ||||
|
685 | def expand(self, tmpl, mapping): | |||
|
686 | """Perform expansion over a literal template | |||
|
687 | ||||
|
688 | No user aliases will be expanded since this is supposed to be called | |||
|
689 | with an internal template string. | |||
|
690 | """ | |||
|
691 | func, data = self._parse(tmpl) | |||
|
692 | return self._expand(func, data, mapping) | |||
|
693 | ||||
|
694 | def _expand(self, func, data, mapping): | |||
675 | # populate additional items only if they don't exist in the given |
|
695 | # populate additional items only if they don't exist in the given | |
676 | # mapping. this is slightly different from overlaymap() because the |
|
696 | # mapping. this is slightly different from overlaymap() because the | |
677 | # initial 'revcache' may contain pre-computed items. |
|
697 | # initial 'revcache' may contain pre-computed items. |
General Comments 0
You need to be logged in to leave comments.
Login now