Skip to content

Commit

Permalink
feat: add beet.contrib.template_context
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Apr 23, 2021
1 parent 55fbe92 commit 12bc6ef
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions beet/contrib/template_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Plugin that exposes the beet context in templates"""


from beet import Context


def beet_default(ctx: Context):
ctx.template.env.globals["ctx"] = ctx
1 change: 1 addition & 0 deletions examples/load_scoreboard/beet.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"require": ["beet.contrib.template_context"],
"data_pack": {
"load": ["src"],
"render": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
#!set obj2 = generate_objective("foo")

scoreboard players operation @s {{ obj1 }} += @s {{ obj2 }}

#!set generate = ctx.generate["thing"]
#!set obj1 = generate.objective()
#!set obj2 = generate.objective("foo")

scoreboard players operation @s {{ obj1 }} += @s {{ obj2 }}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
scoreboard players operation @s 78g8qs26j9ajw += @s 2k6kiizeukf3w

scoreboard players operation @s 5w2mdgpu9wvnf += @s 79agx41duqbaj
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
scoreboard objectives add from_config dummy
scoreboard objectives add 78g8qs26j9ajw dummy "load_scoreboard.0"
scoreboard objectives add 2k6kiizeukf3w dummy "load_scoreboard.foo"
scoreboard objectives add 5w2mdgpu9wvnf dummy "load_scoreboard.thing.0"
scoreboard objectives add 79agx41duqbaj dummy "load_scoreboard.thing.foo"

0 comments on commit 12bc6ef

Please sign in to comment.