Create custom file templates for your project.
- File GitHub issues anytime you run into unexpected situations/bugs.
- Fork our project, send us PRs!
- Create a folder anywhere in your project matching the templates path setting.
By default, the path is set to
blueprint-templates
. (See Extension Settings if you would like to change this)
- Create a template group by adding a new folder under the blueprint templates storage folder
- Add a template to the group by creating a new file
- Right click on the file or folder in the explorer
- Select "New file from template"
- Enter a name
To change the default storage location for where Blueprint templates are stored,
navigate to settings.json
or ⌘,
under Visual Studio Code preferences and
change the blueprint.templatesPath
setting
Example:
// Where your Blueprint templates are stored. Templates are loaded relative to your workspace root path. Defaults to ./blueprint-templates
Examples:
"blueprint.templatesPath": [
"./blueprint-templates",
"../path-one-level-up-from-workspace",
"~/path-from-home-folder",
"/path-from-root
]
Helper Name | Example Use In Templates | Example Use in File/Folder Names | Sample Result |
---|---|---|---|
{none} | {{name}} | __name__ | {No transform applied} |
upperCase | {{upperCase name}} | __upperCase_name__ | THIS IS UPPERCASE |
lowerCase | {{lowerCase name}} | __lowerCase_name__ | this is lowercase |
camelCase | {{camelCase name}} | __camelCase_name__ | thisIsCamelCase |
pascalCase | {{pascalCase name}} | __pascalCase_name__ | ThisIsPascalCase |
snakeCase | {{snakeCase name}} | __snakeCase_name__ | this_is_snake_case |
upperSnakeCase | {{upperSnakeCase name}} | __upperSnakeCase_name__ | THIS_IS_UPPER_SNAKE_CASE |
kebabCase | {{kebabCase name}} | __kebabCase_name__ | this-is-kebab-case |
lowerDotCase | {{lowerDotCase name}} | __lowerDotCase_name__ | this.is.lower.dot.case |
Dynamic Template Variables provide template replacements at the time of file creation in addition to the standard name. The dynamic replacement token should conform to the format of {{ $<inputName> }}
(we will search for a $
within {{ }}
).
For each dynamic token detected, a dialog will appear during the New file from template
workflow. This input will be substituted into the template at the appropriate places.
For exapmle this template:
function myFunction() {
print("{{ $input }} comes before {{$2}} but not before {{ uppercase $input }}");
}
will show two additional dialogs. One for $input
and one for $2
. The same transforms that can be used on name can be used for dynamic template. Dynamic templates currently do not work within filenames.
You can optionally include a "manifest.json" file in your template folders. This enables a few additionally points of customization.
key | Description of Use |
---|---|
suffixesToIgnoreInInput | If the value is "component" for instance, if user enters "My First Component" as the input -- "My First" will be used in the substitutions. This is to enable you to put "Component" in the template and not have to worry about the user entering it or not. |
createFilesInFolderWithPattern (DEPRECATED) | Create your template files within a folder -- uses the same transfrom as you would use during naming your files and folders. This is possible now by just creating a top-level folder in your template. Previously we did not support folders within folders. You should use that technique instead of using this key. |
Example templates can be found here: blueprint-examples
We will continue to add new templates that we think may be helpful to use!
- Adds support for Dynamic Template Variables. You can now have multiple unique tokens within your templates that will get replaced with user input during file creation.
- Adds UPPER_SNAKE_CASE transform (upperSnakeCase_name or {{upperSnakeCase name}})
- Adds ability to use no transform for files names (use name token)
- Adds number of steps and current step to UI for user input
- Skip content replacement on files that cannot read by handlebars. Useful for non-text files like images and video.
Bug Fix: Fixes detection of possible overwrites on file creation.
Cleanup of template selection user interface; the template name is now emphasized again.
Allow templates to include hidden folders and files. System created files (Thumbs.db, .DS_Store, etc. are still ignored).
Added two new transform helpers: lowerCase and upperCase.
Adds ability to provide multiple folders of templates. Useful for using both a project local and a shared (global) templates.
Template folder paths also now expand ~ to the home directory.
Added a new transform helper: lowerDotCase!
Now supports non-unix paths, AKA Windows support!
You can now create folders and nested folder/file structures inside a template folder. Folder names inside a template folder can be templated the same way that file names are.
Fixes missing dependency in initial release.