Skip to content

Commit

Permalink
Fix render_func calling
Browse files Browse the repository at this point in the history
  • Loading branch information
BAntonellini committed Sep 12, 2023
1 parent ffdf136 commit 66bd897
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/dbt_core_interface/dbt_templater/templater.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def from_string(*args, **kwargs):

def render_func(in_str):
env.add_extension(SnapshotExtension)
return env.from_string(in_str, globals=globals)
template = env.from_string(in_str, globals=globals)
return template.render()

local.render_func = render_func

Expand Down Expand Up @@ -197,7 +198,7 @@ def _unsafe_process(self, fname, in_str, config=None):
# will still be null at this point. If so, we replace it with a lambda
# which just directly returns the input , but _also_ reset the trailing
# newlines counter because they also won't have been stripped.
if render_func is None:
if local.render_func is None:
# NOTE: In this case, we shouldn't re-add newlines, because they
# were never taken away.
n_trailing_newlines = 0
Expand All @@ -207,8 +208,10 @@ def render_func(in_str):
"""A render function which just returns the input."""
return in_str

local.render_func = render_func

# At this point assert that we _have_ a render_func
assert render_func is not None
assert local.render_func is not None
raw_sliced, sliced_file, templated_sql = self.slice_file(
source_dbt_sql,
config=config,
Expand Down

0 comments on commit 66bd897

Please sign in to comment.