Template

class rmote.tools.template.Template[source]

Bases: Tool

Built-in tool that renders Mako-like templates on the remote side.

All three methods execute on the remote process. See Templating for a full description of the template syntax.

static render(template, **kwargs)[source]

Compile template and render it with kwargs as the variable namespace.

Parameters:
  • template (Text) – Template source string.

  • **kwargs (object) – Variables available inside the template.

Return type:

Text

Returns:

The rendered string.

static render_compiled(template, **kwargs)[source]

Render a pre-compiled Template instance.

Use this method when the template was compiled locally and passed as an argument to avoid re-compiling it on the remote side.

Parameters:
  • template (Template) – A Template instance (picklable).

  • **kwargs (object) – Variables available inside the template.

Return type:

Text

Returns:

The rendered string.

static render_file(path, **kwargs)[source]

Read the template file at path on the remote host and render it.

Parameters:
  • path (Text) – Absolute path to the template file on the remote filesystem.

  • **kwargs (object) – Variables available inside the template.

Return type:

Text

Returns:

The rendered string.