2022-08-06 21:22:47 -07:00
|
|
|
import textwrap
|
|
|
|
from pathlib import Path
|
|
|
|
|
2023-07-04 10:59:51 -07:00
|
|
|
from jinja2_simple_tags import StandaloneTag
|
|
|
|
from rolltable.tables import RollTable as _RT
|
|
|
|
|
2022-08-06 21:22:47 -07:00
|
|
|
|
|
|
|
class RollTable(StandaloneTag):
|
|
|
|
tags = {"rolltable"}
|
|
|
|
|
2023-07-04 10:59:51 -07:00
|
|
|
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)
|