Skip to content

Commit

Permalink
fix: template
Browse files Browse the repository at this point in the history
  • Loading branch information
robot9706 committed Dec 14, 2024
1 parent e6bf95a commit 9ebd8c6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions web/crux/src/domain/template.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { UniqueKeyValue } from './container'

const applyTemplate = (template: string, inputValue: string, templateValue: string): string =>
inputValue.replace(new RegExp(`{{\\s*${template}\\s*}}`), templateValue)
const applyTemplate = (template: string, inputValue: any, templateValue: string): any => {
if (typeof inputValue !== 'string') {
return inputValue
}

return inputValue.replace(new RegExp(`{{\\s*${template}\\s*}}`), templateValue)
}

const applyTemplatesOnInput = (input: UniqueKeyValue, templates: Record<string, string>) => {
Object.entries(templates).forEach(entry => {
const [template, templateValue] = entry
if (!templateValue) {
if (!templateValue || !input.value) {
return
}

Expand Down

0 comments on commit 9ebd8c6

Please sign in to comment.