render template from string may raise a UndefinedException in case a variable is undefined
(self, string)
| 120 | raise UndefinedException(err) from exc |
| 121 | |
| 122 | def generate_string(self, string): |
| 123 | """ |
| 124 | render template from string |
| 125 | may raise a UndefinedException |
| 126 | in case a variable is undefined |
| 127 | """ |
| 128 | if not string: |
| 129 | return '' |
| 130 | try: |
| 131 | return self.env.from_string(string).render(self.variables) |
| 132 | except UndefinedError as exc: |
| 133 | err = f'undefined variable: {exc.message}' |
| 134 | raise UndefinedException(err) from exc |
| 135 | |
| 136 | def generate_dict(self, dic): |
| 137 | """ |