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

Add support for placeholders in templates #1

Open
maciej-adamus opened this issue Jun 23, 2023 · 7 comments
Open

Add support for placeholders in templates #1

maciej-adamus opened this issue Jun 23, 2023 · 7 comments

Comments

@maciej-adamus
Copy link
Contributor

maciej-adamus commented Jun 23, 2023

Add support placeholders, like it is done in built-in code snippets. The idea is such that you will be guided through filling in additional variables after creating a file from the template, like after inserting a snippet. Would submit a PR myself, but I am not at all familiar with writing vscode extensions 😢

@maciej-adamus maciej-adamus changed the title Add support placeholders in templates Add support for placeholders in templates Jun 23, 2023
@maciej-adamus
Copy link
Contributor Author

This is the only feature that I miss in this ext, otherwise it is perfect

@gautier-lefebvre
Copy link
Owner

hi @maciej-adamus

Do you have an example of how you would use it and what it would render? So I can understand what you mean exactly

@gautier-lefebvre
Copy link
Owner

What I understand right now is basically having some arbitrary variables inside the template that you would be prompted for when creating a file from the template

const <%= baseFileName %> = () => (
  <div><%= someArbitraryVariable %></div>
);

Where baseFileName would be filled by the extension, and someArbitraryVariable would be prompted at creation time

@gautier-lefebvre
Copy link
Owner

You can update the extension, this is what it looks like with my previous example:

image

Feel free to tell me if it answers your use case :)

@maciej-adamus
Copy link
Contributor Author

maciej-adamus commented Jun 26, 2023

What you proposed would solve my use-case, but I think that better would be to fill the additional variables in-context, so after the file is created. What I am looking for is a behavior more akin to the vscode snippets - you add placeholders ($1, $2 and so on) in the file template, and then, after you create a new file from the template, your cursor is placed in the location of the first placeholder, so that you can fill it in. Then when you press TAB, the cursor jumps to the second placeholder and so on.

@gautier-lefebvre
Copy link
Owner

Ok I see better what you mean, although tbh I have absolutely no idea how to do this with the VSCode API. I'll try something out, that might be a better UX than what we currently have.

In the meantime I believe we have a usable solution to the problem, which was something that I had in the back of my mind for a while

@maciej-adamus
Copy link
Contributor Author

Just noticed this is actually already implemented in the vscode snippets out of the box

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

No branches or pull requests

2 participants