BasPH commented on a change in pull request #5461: [AIRFLOW-4835] Refactor
render_template
URL: https://github.com/apache/airflow/pull/5461#discussion_r309209865
##########
File path: airflow/models/baseoperator.py
##########
@@ -636,51 +636,50 @@ def __setstate__(self, state):
self.__dict__ = state
self._log = logging.getLogger("airflow.task.operators")
- def render_template_from_field(self, attr, content, context, jinja_env):
+ def render_template(
+ self, content: Any, context: Dict, jinja_env:
Optional[jinja2.Environment] = None
+ ) -> Any:
"""
- Renders a template from a field. If the field is a string, it will
- simply render the string and return the result. If it is a collection
or
- nested set of collections, it will traverse the structure and render
- all elements in it. If the field has another type, it will return it
as it is.
+ Render a templated object. The object may be nested and will be
templated recursively.
+
+ :param content: Content to template. Only strings can be templated
(may be nested).
Review comment:
Indeed only strings will ultimately be templated. The message to convey is
that you can also supply e.g. a list of strings, which will be templated. A
list itself won't be templated, but the function will iterate over all elements
in a list and template if type == str, hence the "may be nested".
Does that make sense and should I word it differently?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services