Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying custom extension in create_file #1456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gergesh
Copy link

@gergesh gergesh commented Sep 13, 2024

No description provided.

@Zachatoo
Copy link
Collaborator

Thanks for contributing!

Can you help me understand the use case? I believe tp.file.create_new should work as is when referencing a template file that is of any file type, without having to explicitly define the extension.

@@ -136,8 +137,8 @@ export class Templater {
}
}

const extension =
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the case, as you can tell from this line that overrides the extension in the newly created note

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if you're providing a string template, as opposed to providing a file for the template. If you're providing a file then it will use the same extension as the provided file. I've used this for .canvas files in the past. Are you generating a string in code and creating a file using that generated string?

I'm hesitant to add yet another argument to this function if it isn't strictly needed, it has a lot of arguments already, and I don't suspect this argument would be used much since most use cases can already be covered.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My usecase isn't too niche (I believe), I have a script that prompts for a filename and creates a file named "yyyy-mm-dd-filename" (which I'd like to be able to support arbitrary extensions)

@gergesh
Copy link
Author

gergesh commented Oct 19, 2024

To be specific on my usage: I'm simply trying to create a new file with a custom extension from a template script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants