| OLD | NEW |
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Setups jinja2 environment to be reused by all components and services.""" | 5 """Setups jinja2 environment to be reused by all components and services.""" |
| 6 | 6 |
| 7 import datetime | 7 import datetime |
| 8 import os | 8 import os |
| 9 import urllib | 9 import urllib |
| 10 | 10 |
| 11 from components import utils | 11 from components import utils |
| 12 utils.import_jinja2() | 12 utils.import_jinja2() |
| 13 | 13 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 """Shorthand to render a template. | 194 """Shorthand to render a template. |
| 195 | 195 |
| 196 It includes default useful parameters used in most templates/base.html. | 196 It includes default useful parameters used in most templates/base.html. |
| 197 | 197 |
| 198 TODO(maruel): Uniformize this. | 198 TODO(maruel): Uniformize this. |
| 199 """ | 199 """ |
| 200 data = _get_defaults() | 200 data = _get_defaults() |
| 201 data.update(params or {}) | 201 data.update(params or {}) |
| 202 data.setdefault('now', utils.utcnow()) | 202 data.setdefault('now', utils.utcnow()) |
| 203 return get_jinja_env().get_template(name).render(data) | 203 return get_jinja_env().get_template(name).render(data) |
| OLD | NEW |