Skip to content

Commit

Permalink
Helper function for partial names
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfarrell76 committed Oct 17, 2023
1 parent ea7b701 commit 954adfd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Transcend Inc.",
"name": "@transcend-io/handlebars-utils",
"description": "Utility functions for handlebars templating with Transcend - available in node and client side.",
"version": "1.0.1",
"version": "1.1.0",
"homepage": "https://github.com/transcend-io/handlebars-utils",
"repository": {
"type": "git",
Expand Down
21 changes: 21 additions & 0 deletions src/createHandlebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ import { cases } from './change-case';
// TODO: https://transcend.height.app/T-30349 - de-duplicate this with cli and node-util
export { Handlebars };

/**
* Given a file name, return the desirable name for a handlebars extension
* The extension is in camel case without the file suffix, and all slashes
* and spaces get removed
*
* @param fileName - Filename
* @param extension - File extension
* @returns Partial name
*/
export function getPartialNameFromFileName(
fileName: string,
extension = 'hbs',
): string {
return cases.camelCase(
fileName
.slice(0, fileName.length - `.${extension}`.length)
.split('/')
.pop(),
);
}

/**
* Input for creating a handlebars instance
*/
Expand Down

0 comments on commit 954adfd

Please sign in to comment.