Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/3axap4eHko/file-templates-manager

VSCode file templates manager extension
https://github.com/3axap4eHko/file-templates-manager

template templates vscode vscode-extension

Last synced: 3 months ago
JSON representation

VSCode file templates manager extension

Awesome Lists containing this project

README

        

# File Templates Manager for VSCode

File Templates Manager for VSCode allows you to manage your file templates and generate files from them.

:heart: Like it? :coffee: [![Donate][donate-image]][donate-url]

![Screen Cast][screen-cast]

## Features

File Template Manager is powerful extension with following features that improve your productivity and do routine work for you.

### Manage file template

![Explorer][explorer]

![Template Picker][template-picker]

### Interactive integrated `doT` template engine

* `{{ }}` - evaluation
* `{{= }}` - interpolation
* `{{! }}` - interpolation with encoding
* `{{# }}` - compile-time evaluation/includes and partials
* `{{## #}}` - compile-time defines
* `{{? }}` - conditionals
* `{{~ }}` - array iteration

[Full Documentation](http://olado.github.io/doT/index.html) of `doT` template engine

---
Variables available by default

- `DIR` - directory of created file
- `NAME` - name from input prompt
- `FILE` - `NAME` + template extension
- `FILE_PATH` - `DIR` + `FILE`
- `USER` - name of user
- `DATE` - date of file creation
---

Evaluation and interpolation example for `HTML` file

```html
{{ for(let i = 0; i < 10; i++ ) }}

Item {{=i}}

```

result is

```html

Item 0

Item 1

Item 2

Item 3

Item 4

Item 5

Item 6

Item 7

Item 8

Item 9

```

---

Select prompt example for `C#` language file

```cs
using System;

{{#def.select('TYPE', 'Select file type', ['class','interface','struct','enum'])}}
/*
{{=$.NAME}} {{=$.TYPE}}
*/
public {{=$.TYPE}} {{=$.NAME}}
{

}
```

you will see a prompt

![Select value][type-selector]

and get result for `class` type

```cs
using System;

/*
CSharp class
*/
public class CSharp {

}
```

---

`tsconfig.json` example file

```js
{{#def.select('MODULE', 'Specify module code generation', ['none','commonjs','amd','system','umd','es6','es2015','esnext'])}}
{{#def.select('TARGET', 'Specify ECMAScript target version', ['es3','es6','es2016','es2017','esnext'])}}
{{#def.confirm('SOURCE_MAP', 'Should generate corresponding .map file?')}}
{
"compilerOptions": {
"module": "{{=$.MODULE}}",
"target": "{{=$.TARGET}}",
"sourceMap": {{=$.SOURCE_MAP}}
},
"exclude": [
"node_modules"
]
}
```

## Extension Settings

This extension contributes the following settings:

* `templates.showExplorer`: show/hide templates explorer
* `templates.customVars`: you can define custom variables like AUTHOR, LICENSE, PROJECT and etc

## License
[The MIT License](http://opensource.org/licenses/MIT)
Copyright (c) 2019 Ivan Zakharchanka

[screen-cast]: https://github.com/3axap4eHko/file-templates-manager/raw/master/docs/screen-cast.gif 'File Templates Manager Screen Cast'
[explorer]: https://github.com/3axap4eHko/file-templates-manager/raw/master/docs/explorer.png 'File Templates Manager Explorer'
[template-picker]: https://github.com/3axap4eHko/file-templates-manager/raw/master/docs/template-picker.png 'File Templates Manager Picker'
[type-selector]: https://github.com/3axap4eHko/file-templates-manager/raw/master/docs/select-type.png 'File Templates Manager Selector'

[donate-image]: https://img.shields.io/badge/Donate-PayPal-green.svg 'PayPal Donate'
[donate-url]: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LJWEQTUUZ977C&lc=US&item_name=file-templates-manager&currency_code=USD