| 131 | """Holds compile time information for us.""" |
| 132 | |
| 133 | def __init__(self, eval_ctx, parent=None, level=None): |
| 134 | self.eval_ctx = eval_ctx |
| 135 | self.symbols = Symbols(parent and parent.symbols or None, |
| 136 | level=level) |
| 137 | |
| 138 | # a toplevel frame is the root + soft frames such as if conditions. |
| 139 | self.toplevel = False |
| 140 | |
| 141 | # the root frame is basically just the outermost frame, so no if |
| 142 | # conditions. This information is used to optimize inheritance |
| 143 | # situations. |
| 144 | self.rootlevel = False |
| 145 | |
| 146 | # in some dynamic inheritance situations the compiler needs to add |
| 147 | # write tests around output statements. |
| 148 | self.require_output_check = parent and parent.require_output_check |
| 149 | |
| 150 | # inside some tags we are using a buffer rather than yield statements. |
| 151 | # this for example affects {% filter %} or {% macro %}. If a frame |
| 152 | # is buffered this variable points to the name of the list used as |
| 153 | # buffer. |
| 154 | self.buffer = None |
| 155 | |
| 156 | # the name of the block we're in, otherwise None. |
| 157 | self.block = parent and parent.block or None |
| 158 | |
| 159 | # the parent of this frame |
| 160 | self.parent = parent |
| 161 | |
| 162 | if parent is not None: |
| 163 | self.buffer = parent.buffer |
| 164 | |
| 165 | def copy(self): |
| 166 | """Create a copy of the current one.""" |