@@ -121,7 +121,8 @@ def from_string(*args, **kwargs):
121121
122122 def render_func (in_str ):
123123 env .add_extension (SnapshotExtension )
124- return env .from_string (in_str , globals = globals )
124+ template = env .from_string (in_str , globals = globals )
125+ return template .render ()
125126
126127 local .render_func = render_func
127128
@@ -197,7 +198,7 @@ def _unsafe_process(self, fname, in_str, config=None):
197198 # will still be null at this point. If so, we replace it with a lambda
198199 # which just directly returns the input , but _also_ reset the trailing
199200 # newlines counter because they also won't have been stripped.
200- if render_func is None :
201+ if local . render_func is None :
201202 # NOTE: In this case, we shouldn't re-add newlines, because they
202203 # were never taken away.
203204 n_trailing_newlines = 0
@@ -207,8 +208,10 @@ def render_func(in_str):
207208 """A render function which just returns the input."""
208209 return in_str
209210
211+ local .render_func = render_func
212+
210213 # At this point assert that we _have_ a render_func
211- assert render_func is not None
214+ assert local . render_func is not None
212215 raw_sliced , sliced_file , templated_sql = self .slice_file (
213216 source_dbt_sql ,
214217 config = config ,
0 commit comments