Skip to content

Commit

Permalink
docs: Provided API documentation for render_text_template and render_…
Browse files Browse the repository at this point in the history
…template (#138)
  • Loading branch information
Gallaecio authored and rennerocha committed Sep 3, 2019
1 parent f0bc473 commit b49e6c2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions spidermon/contrib/actions/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,25 @@ def get_template(self, name):
return template_loader.get_template(name)

def render_text_template(self, template):
"""Render a Jinja2 template given in *template* as a string.
For example::
action.render_text_template('{{ monitors_failed }} monitors failed!')
"""
template = Template(template)
return template.render(self.get_template_context())

def render_template(self, template):
"""Render the Jinja2 template file named *template*.
It uses :data:`spidermon.templates.template_loader` to resolve
*template* to an actual template file.
For example::
action.render_template('mytemplate.html')
"""
template = self.get_template(template)
return template.render(self.get_template_context())

Expand Down

0 comments on commit b49e6c2

Please sign in to comment.