-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor naming macro to use snake_case (#431)
* Reformat naming macros to use snake_case * Add test change for naming schema * Namespace slugify() * Drop slugify test * Fix slugify test result * Revert removing homerolled slugify * Remove dupe macro name * Update slugify macro to replace hyphens * Update hyphen test * Update other tests * Fix order of regex * Rename stub DB * Revert "Add test change for naming schema" This reverts commit 20e9954.
- Loading branch information
Showing
5 changed files
with
31 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
-- Variation of dbt_utils.slugify macro using kebab-case instead of snake_case | ||
{% macro kebab_slugify(string) %} | ||
-- Variation of dbt_utils.slugify macro using strict snake_case | ||
{% macro slugify(string) %} | ||
{#- Lower case the string -#} | ||
{% set string = string | lower %} | ||
|
||
{#- Replace spaces, slashes, and underscores with hyphens -#} | ||
{% set string = modules.re.sub("[ _/]+", "-", string) %} | ||
{#- Replace spaces, slashes, and hyphens with underscores -#} | ||
{% set string = modules.re.sub("[ /-]+", "_", string) %} | ||
|
||
{#- Only take letters, numbers, and hyphens -#} | ||
{% set string = modules.re.sub("[^a-z0-9-]+", "", string) %} | ||
{% set string = modules.re.sub("[^a-z0-9_]+", "", string) %} | ||
|
||
{{ return(string) }} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters