Skip to content

Commit

Permalink
add jinja render of db template filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Nov 6, 2023
1 parent e833963 commit 8383bdb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ibek/render_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def add_row(self, filename: str, args: Dict[str, Any], entity: Entity) -> None:
Adding a new template file if it does not already exist.
Convert all arguments to strings.
"""
filename = render_with_utils(dict(entity), filename)

if filename not in self.render_templates:
# for new filenames create a new RenderDbTemplate entry
headings = [str(i) for i in list(args.keys())]
Expand Down
7 changes: 7 additions & 0 deletions tests/samples/outputs/all.ioc.subst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ pattern
{ "AllObject Two", "Ref1", "1.0", "True" }
}

file "jinjified1.db" {
pattern
{ "name" }
{ "AllObject One" }
{ "AllObject Two" }
}

file "test.db" {
pattern
{ "name", "ip", "value" }
Expand Down
3 changes: 3 additions & 0 deletions tests/samples/yaml/all.ibek.support.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,6 @@ defs:
my_object:
my_float:
my_bool:
- file: jinjified{{ my_int }}.db
args:
name:

0 comments on commit 8383bdb

Please sign in to comment.