@mikezimm/fps-core-v7
Version:
Library of reusable core interfaces, types and constants migrated from fps-library-v2
40 lines (39 loc) • 1.42 kB
TypeScript
/**
* const regex = /{{(.*?)}}/g;
*
* function replaceHandlebars(template, data) {
// Create a regular expression to match handlebars expressions
const regex = /{{(.*?)}}/g;
// Replace each expression with the corresponding value from the data object
return template.replace(regex, (match, expression) => {
// Evaluate the expression using the data object as the context
return eval(expression);
});
}
*/
/**
* This function will replace
* <h2>{{Title}}</h2>
*
* with the Title property of the item passed in:
* <h2>item.Title</h2>
*
* @param item
* @param handleBarString
* @param emptyIfSubEmpty
* @param replaceSlashDots >> will replace Author/Title with AuthorTitle - consistant with the way Drilldown works
* @returns
*/
export declare function replaceHTMLHandleBars(item: any, handleBarString: string, emptyIfSubEmpty: boolean, replaceSlashDots?: boolean): string;
/**
* This will get all properties that are surrounded by handlebars from a string and put them in an array
* Recommended to get item props to fetch or select
* Does NOT remove any / or . characters.
*
* @param handleBarString
* @param removeEmpty
* @param removeDups
* @returns
*/
export declare function getHandleBarPropsFromString(handleBarString: string, removeEmpty: boolean, removeDups: boolean): string[];
//# sourceMappingURL=handleBarsHTML.d.ts.map