yuanhjty / code-template-tool Goto Github PK
View Code? Open in Web Editor NEWVSCode extension to generate code based on the template
License: MIT License
VSCode extension to generate code based on the template
License: MIT License
Is it possible to add a setting that determines if to use the current interface or the command pallete?
I think the process would feel more fluid and intuitive if you can continue to answer questions in command pallete.
Just an idea!
How can I set author and email generally? There var fo it in the sample templates, but it don't work. It makes also no sense to defined theses for each template.
First of all, amazing piece of work and an amazing extension. Thank you for your contribution. I just have one small issue which I would very much appreciate if you can fix it.
Snippets are saved in the following places:
%APPDATA%\Code\User\snippets
$HOME/Library/Application Support/Code/User/snippets
$HOME/.config/Code/User/snippets
So, please provide us with a value {appdir}
for Templates Path
setting which resolves to:
%APPDATA%\Code\User
$HOME/Library/Application Support/Code/User
$HOME/.config/Code/User
I would like to store my templates along with snippets.
现在新建页面的输入项中输入中文,模板生成文件中会显示为空格(中文用于编写页面描述)
If i open the context menu on a file in the sidebar, it would be very useful if that file/filename can be used as a parameter for the template. For example if i have a file "temp.cs", i could make a template which uses filename to create a file "temp.md".
Our folder and css class naming is kebabCase and we would like our naming in JS to be camelCase.
Also we're using .c_[component-name]
as our css naming convention. Only way to get this to work is to add a prefix to an extra variable. Because when I use .c____var___ {}
inside the template all underscores are replaced. even the additional first .c**_**
We can add multiple (3) vars to accomplish this but I was wondering if you could support case formatting inside templates and only replace three underscores before the var. So depending of the template we could convert the variable to a preferred case and can use an underscore before a var name. This way we can use a single var to accomplish all above.
{ "name": "New Object Template", "variables": [ "objectName" ] }
for example, add default
field in variables
"variables": [
{
"name": "abcDef",
"case": "camelCase",
"prefixUnderscore": 3,
"default": "defaultValue"
}
]
___abcDef___
will compile to defaultValue
when abcDef
is empty
add a property in template.config.json
to specify which file should be focus when created
补充: 这样,多人可以通过模板保持一致了.
支持多个github源, 并且定义别名, 如:
umi https://github.com/...../umi
dva https://github.com/.../dva
为不同项目可以设置使用哪个源的模板.
It would be very helpful to have the possibility to use the upper and lover case variables in the templates.
In my case I want to define a camel case variable myModueName and use in the templates also MYMODULENAME (e.g. as prefix for C defines) as also mymoduleame (e.g. as prefix for the static function/variable names etc.). As the extension has already a great number of complex cases supported this request might be a really a easy one from the implementation point of view but very helpful for a lot of uses cases.
just like the variables supported in the Templates Path {home}
{workspace}
and so on
Thanks for the great work. Currently I'm setting up your plugin inside our project workflow and i've got some feature requests to make it even better.
This way we can limit the use of a mouse and quickly add templates with vars inside our projects.
The plugin is not working since the upgrade to vscode 1.56
. All I see when trying to create file/folder from template is an empty white input:
Verified by downgrading to 1.55, where everything's working fine.
If you need more information to replicate, please let me know.
Thanks a lot in advance for taking a look 🙏
At the following version of visual studio code:
Versión: 1.65.2 (system setup)
Commit: c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1
Fecha: 2022-03-10T14:33:55.248Z
Electrón: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19042
The following error is obteined at the extension page and when making use of the extension, before rendering the forms.
Error loading the web view: Error: Could not register service workers: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state..
Hallo yuanhjty, great extension with a lot of potential.
I miss the snake-case-style with uppercase letters.
For example:
//template.config.json
{
"name": "Magento 1 Extension",
"variables": ["extension_name"]
}
Value of extension_name = namespace_extension
Use in a template:
___Extension_Name___
Exspected result is "Namespace_Extension", but the result is "NamespaceExtension".
For building for Magento you need snake-case-style with uppercase letters. It would be great, if you can implement this.
NobyNa
I configured the extension as mentioned in the documentation. The only setting I have overwritten is the Template Path to use {workspace}/templates
.
This is how one of my template looks -
+ ___component-name___
- ___component-name___.component.tsx
- ___component-name___.module.scss
- ___component-name___.interfaces.ts
- index.ts
The problems I encountered are -
+ ___component-name___
. It just generates all the files directly inside the directory I invoked this command on. I right click on a directory and select "New File/Folder from template". I would expect it to 1st generate the base directory and then create all files inside that directory. As you can check in the attached screenshot, the template didn't create the base directory, but generated all the files directly inside "components" folder.I am using VSCode Version: 1.43.1 & latest version of this extension.
Thanks for the help.
It would be nice with a setting to open the newly created file.
Very convenient and configurable tool. Thanks!
I would like to request the ability to select which menu options are included in the context menu. "Edit Templates" and "Reload Templates" should rarely be used and I would prefer they only be accessible from the command palette or keyboard shortcut.
Consider one case that developer want to use a boolean variable to control whether to show some codes in template.
for example:
{{if show}}
<h2>show something</h2>
{{/if}}
Now, the work around is creating a new template. But it's difficult to use this method when the boolean variables are more than three or more.
I have two instances where the replacement values do not work as expected.
The first is in implementing a common pattern for NextJS pages where the eventual file or folder name requires to be an all lowercase term followed by id and wrapped with square brackets - so a file or folder may be named [cityaliasid].
I have a variable templateName: cityAlias.
if I use [___templatename___id]
as the value for the filename or the folder the value is not replaced when creating the file or folder. However if I use [___templateName___]
the value IS replaced but of course the result includes a capital which needs to be dealt with after the template has run.
The other case is in the replacement of a value within a file where I have a pathname that must be preceded by "/" In this case the template contains path={"/___templatename___"}
- again the value is not replaced.
All other instances of variables in the templates and filenames are working exactly as expected and correctly case.
I guess the issues result from RegEx syntax being confused by the character appearing immediately before the template.
在vscode的首选项中找不到
Not found in vscode's preferences
This would help a lot when using remote hosts where templates are in another directory than in local mode.
Like:
~/templates1:/opt/global_dev_templates
Support comment on template and won't be copyed to generated file
支持模板上的注释, 不会被复制到生成文件中.
Hi there! First, that you so much for this extension it's a time saver! I'm running into the following issue:
Sass relies on the_file-name.scss
naming pattern for identifying files that should output a css file. I was trying to auto generate file names and imports with this naming convention in mind:
// template.config.json
{
"name": "React Component",
"variables": ["componentName"]
}
Then I attempted to create a scss file with an extra _ in the name to be included in the file name: ____component-name___.scss
to create _react-component.scss
.
I also imported this file into a JS file:
// index.js
import './____component-name___.scss'; // -> import './_react-component.scss';
I expected that any additional underscores (_) would be respected and remain unchanged.
All extra underscores (_) are replaced with the variable string:
____component-name___.scss
creates react-component.scss
And
// index.js
import './____component-name___.scss'; // -> import './react-component.scss';
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.