rioj7/vscode-file-templates

Can an input be used to name the file?

Closed this issue · 5 comments

I have tried using
##@@## ${input:migration:}
as the first line of the file. But I never get prompted, and an attempt if made to create a file with the literal ${input:migration:} -- which is invalid in my OS.

##@@## ${dateTimeFormat}

Works as expected.

Thanks

rioj7 commented

@i616solutions

From the readme

##@@## fileBasenameNoExtension

fileBasenameNoExtension is text that can contain variables (not the input, snippet and cursor)

if you don't use the ##@@## first line you are asked with an input box for the filename, the same functionality as an input variable

Fair enough. What I was hoping to accomplish was to combine the two. I need a specific format for the filename:

2022_04_08_144226_create_notes_table.php

So I was hoping to use an input to get the text part, then use a custom date format to capture the date part.

But I will pick one and and just rename the file manually after its created.

Thanks for the feedback, and for all the work in putting this together.

rioj7 commented

@i616solutions you only showed an input variable on the line but

##@@## ${dateTimeFormat}-${input:migration:}

is a different and useful one.

I will have a look to allow ${input} in the filename line

rioj7 commented

@i616solutions Can you try v1.8.0

Yes, I updated to 1.8.0 and

##@@## ${dateTimeFormat}-${input:migration:}

Worked perfectly. For what its worth, the format of the name is used in Laravel Migrations.