RenderTemplate¶
Render on the target through a connection. render_file reads a path
on that target. See Templating for syntax and local rendering.
- class rmote.tools.template.RenderTemplate[source]¶
Bases:
ToolBuilt-in tool that renders Jinja-like templates with restricted expressions.
Both methods execute on the remote process. See Templating for a full description of the template syntax.
Render locally, then send the compiled template to another Python process:
>>> from rmote.templates import Template >>> from rmote.sync import Connection >>> from rmote.tools import RenderTemplate >>> Template("Hello, {{ name }}!").render(name="Ada") 'Hello, Ada!' >>> compiled = Template("port={{ port }}") >>> with Connection.from_local() as remote: ... rendered = remote(RenderTemplate.render, compiled, port=8080) >>> rendered 'port=8080' >>> RenderTemplate.render("{% for name in names %}[{{ name }}]{% endfor %}", names=["web", "db"]) '[web][db]'
- static render(template, **kwargs)[source]¶
Render source text or a compiled template with the supplied values.
Source strings are compiled on the receiving host. A supplied
Templatetransfers its intermediate representation and filter classes, and renders without recompilation.