-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HCK-7856: FE DDL of CREATE VIEW should include column_list with colum…
…n comment (#241) * HCK-7856: Include column_list to a view * HCK-7856: Update comment statement * HCK-7856: refactor getViewScript * HCK-7856: Fix the issue with wrong comment placement * HCK-7856: Restore formatter settings * HCK-7856: Fix template * HCK-7856: Improve formatting
- Loading branch information
1 parent
34bdd6a
commit dbd967d
Showing
3 changed files
with
74 additions
and
48 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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const template = (modifiers = '') => new RegExp('\\$\\{(.*?)}', modifiers); | ||
const getAllTemplates = str => str.match(template('gi')) || []; | ||
const parseTemplate = str => (str.match(template('i')) || [])[1]; | ||
|
||
const assignTemplates = (str, templates) => { | ||
return getAllTemplates(str).reduce((result, item) => { | ||
const templateName = parseTemplate(item); | ||
|
||
return result.replace(item, () => { | ||
return templates[templateName] || templates[templateName] === 0 ? templates[templateName] : ''; | ||
}); | ||
}, str); | ||
}; | ||
|
||
module.exports = assignTemplates; |