ninjadog package

Submodules

ninjadog.cli module

ninjadog v0.5.2

Render pug templates to html.

Usage:
ninjadog string [options] <string> ninjadog file [options] <file> ninjadog dir [options] <source> [<destination>] ninjadog - [options] ninjadog -h | –help ninjadog -V | –version
Options:
-h –help show help and exit -V –version show version and exit -f –file <file> the filepath to the template -p –pretty pretty print output -c –context <context> json string to be passed as context -j –with-jinja render jinja2 syntax as well as pug -v –verbose verbose output -n –dry-run verbose output and exit without executing <destination> destination directory to render pug files to

Strings may be passed via pipe using - argument.

i.e.

echo ‘h1 hello {{ name }}’ | ninjadog - -j -c ‘{“name”: “Sam”}’

outputs

<h1>hello Sam</h1>

ninjadog.cli.main(argv: typing.Union[typing.Iterable, NoneType] = None)[source]

Render pug template to stdout.

ninjadog.cli.render_directory(source: pathlib.Path, destination: pathlib.Path = None, **kwargs)[source]

Render a directory of pug templates.

Parameters:
  • source – the source directory
  • destination – the destination directory [default: source]
  • kwargs – arguments that will be passed to the ninjadog renderer

Returns: None

ninjadog.constants module

ninjadog.decorators module

ninjadog.decorators.idempotent(func)[source]

Ensure the function runs only once.

ninjadog.ninjadog module

Main module.

ninjadog.ninjadog.render(string: str = '', file: typing.Union[pathlib.Path, str] = None, context: typing.Any = None, pretty: bool = False, pug_cli_path: str = None, with_jinja: bool = False) → str[source]

Render a pug template through the pug cli.

Parameters:
  • string – a string in pug syntax to be rendered
  • file – the path to a pug template
  • context – the data to be passed to the template
  • pretty – pretty html output
  • pug_cli_path – path to the pug cli
  • with_jinja – render jinja2 template syntax as well

Returns: rendered html

ninjadog.utils module

Module contents

Top-level package for ninjadog.