Skip to content

Commit

Permalink
fixup! fixup! Add basic templating to snow sql
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-turbaszek committed Mar 14, 2024
1 parent 3b0f8b5 commit f70ddff
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/snowflake/cli/api/utils/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,19 @@ def _env_bootstrap(env: Environment) -> Environment:
return env


_RANDOM_BLOCK = "___very___unique___block___to___disable___logic___blocks___"
SNOWFLAKE_CLI_JINJA_ENV = _env_bootstrap(
Environment(
loader=loaders.BaseLoader(),
keep_trailing_newline=True,
variable_start_string="%{",
variable_end_string="}",
block_start_string=_RANDOM_BLOCK,
block_end_string=_RANDOM_BLOCK,
undefined=StrictUndefined,
def get_snowflake_cli_jinja_env():
_random_block = "___very___unique___block___to___disable___logic___blocks___"
return _env_bootstrap(
Environment(
loader=loaders.BaseLoader(),
keep_trailing_newline=True,
variable_start_string="%{",
variable_end_string="}",
block_start_string=_random_block,
block_end_string=_random_block,
undefined=StrictUndefined,
)
)
)


def jinja_render_from_file(
Expand Down Expand Up @@ -147,4 +148,4 @@ def jinja_render_from_file(

def snowflake_cli_jinja_render(content: str, data: Dict | None = None) -> str:
data = data or dict()
return SNOWFLAKE_CLI_JINJA_ENV.from_string(content).render(**data)
return get_snowflake_cli_jinja_env().from_string(content).render(**data)

0 comments on commit f70ddff

Please sign in to comment.