object-replace-mustache
Version:
replace placeholders of an object with a view like you would use mustache.render for strings
19 lines (14 loc) • 414 B
text/typescript
import { delimitersMustache, regexForDelimiters } from './utils'
export type IsTemplateStringOptions = {
delimiters: [string, string]
}
export const isTemplateString = (
str: any,
options?: IsTemplateStringOptions,
): str is string => {
if (!str || typeof str !== 'string') {
return false
}
const regex = regexForDelimiters(options?.delimiters ?? delimitersMustache)
return regex.test(str)
}