dnd/deadsands/site_tools/extensions.py
2022-08-06 21:22:47 -07:00

14 lines
452 B
Python

import textwrap
from rolltable.tables import RollTable as _RT
from jinja2_simple_tags import StandaloneTag
from pathlib import Path
class RollTable(StandaloneTag):
tags = {"rolltable"}
def render(self, sources, frequency='default', die=8, indent=0, **kwargs):
rt = _RT([Path(f'sources/{s}.yaml').read_text() for s in sources],
frequency=frequency, die=die)
return textwrap.indent(rt.as_yaml(), ' ' * indent)