SublimeTmpl
Create File From Templates for ST2/ST3.
Details
Installs
- Total 161K
- Win 128K
- Mac 23K
- Linux 10K
| Oct 29 | Oct 28 | Oct 27 | Oct 26 | Oct 25 | Oct 24 | Oct 23 | Oct 22 | Oct 21 | Oct 20 | Oct 19 | Oct 18 | Oct 17 | Oct 16 | Oct 15 | Oct 14 | Oct 13 | Oct 12 | Oct 11 | Oct 10 | Oct 9 | Oct 8 | Oct 7 | Oct 6 | Oct 5 | Oct 4 | Oct 3 | Oct 2 | Oct 1 | Sep 30 | Sep 29 | Sep 28 | Sep 27 | Sep 26 | Sep 25 | Sep 24 | Sep 23 | Sep 22 | Sep 21 | Sep 20 | Sep 19 | Sep 18 | Sep 17 | Sep 16 | Sep 15 | Sep 14 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Windows | 0 | 1 | 1 | 2 | 1 | 5 | 4 | 4 | 3 | 1 | 0 | 0 | 1 | 6 | 2 | 3 | 2 | 2 | 2 | 3 | 0 | 1 | 4 | 3 | 7 | 5 | 1 | 2 | 0 | 1 | 1 | 1 | 0 | 2 | 0 | 1 | 2 | 5 | 1 | 1 | 0 | 1 | 4 | 1 | 3 | 1 |
| Mac | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 0 |
| Linux | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
Readme
- Source
- raw.githubusercontent.com
SublimeTmpl
A Sublime Text 2/3 plugin for create file from templates.
Installation
Github
Go to the “Packages” directory (Preferences / Browse Packages). Then clone this repository:
$ git clone https://github.com/kairyou/SublimeTmpl.git
Package Control
Install Package Control. Then Package Control: Install Package, look for SublimeTmpl / tmpl and install it.
Usage
Create file with menu
File - New File (SublimeTmpl)Create file with command use
cmd+shift+pthen look fortmpl:
Settings
Default Settings: Preferences > Packages Settings > SublimeTmpl > Settings - Default
Custom settings (*Recommend): Preferences > Package Settings > SublimeTmpl > Settings - User
Default template files: Packages/SublimeTmpl/templates
Custom template files (Recommend): Packages/User/SublimeTmpl/templates/
Project-specific template files (ST3 only): via settings: SublimeTmpl: template_folder key within your sublime-project file (see “Features added” below)
Default key bindings
ctrl+alt+h html
ctrl+alt+j javascript
ctrl+alt+c css
ctrl+alt+p php
ctrl+alt+r ruby
ctrl+alt+shift+p python
Disable shortcuts
If you’re unhappy with default keymap, you can disable keyboard shortcuts with disable_keymap_actions preference of SublimeTmpl.sublime-settings.
Use a comma-separated list of action names which default keyboard shortcuts should be disabled. For example, if you want to disable creat html and css shortcuts, your must set the following value:
"disabled_keymap_actions": "html, css"
To disable all default shortcuts, set value to all.
Features added
custom template files
put your custom template files in
Packages/User/SublimeTmpl/templatesProject-specific template files can be specified in project files, along with overriding other templating options.*.tmplfile support${date}variabledefault “date_format” : “%Y-%m-%d %H:%M:%S” .
*.tmplfile support${saved_filename},${saved_filepath}on save fileEnable:
SublimeTmpl > settings - useradd"enable_file_variables_on_save": true,*.tmplfile support${project_base_name},${project_path}and${platform}NOTE: This will only work with SublimeText 3.0 or above.
Enable:
SublimeTmpl > settings - useradd"enable_project_variables": true,
It is recommended that you put your own custom settings in settings - user. Please see note below in “*Detailed Instructions for Sublime Newbies”
custom variables:
attrcustom the attr variables in settings, example:
"attr": {
"author": "Your Name" ,
"email": "you@example.org",
"link": "http://example.org",
"hello": "word"
}
> The `*.tmpl` file will support `${author}` `${email}` `${link}` `${hello}` variables.
- Project specific overrides via
SublimeTmplattribute in sublime-project file. >
"settings":
{
"SublimeTmpl":
{
"template_folder": "Path\\to\\some\\custom\\template\\folder",
"template_replace_pattern": "{{%s}}",
"enable_project_variables": true,
"enable_file_variables_on_save": true,
"attr": { // Fully overrides "attr" settings (i.e. elements missing here will not attempt to be replaced in template)
"author": "Alternative Name"
},
"project_variables": {
// Allows for use with other template formats, provide mapping here
// "tmpl_formatted_name": "current_template_name"
"project_base_name": "projectbase",
"project_path": "projectpath",
"platform": "plat"
},
"file_variables_on_save": {
// Allows for use with other template formats, provide mapping here
// "tmpl_formatted_name": "current_template_name"
"saved_filename": "name",
"saved_filepath": "filepath"
},
},
},
*Detailed Instructions for Sublime Newbies
Sublime Text keeps settings in bunch of files in a folder. For example, OS X, it is located at
/Users/yourusername/Library/Application Support/Sublime Text 3/Packages
You can navigate to it easily by using the following menu item in Sublime, for example: Sublime Text>Preferences>Browse Packages
Now go to Packages\SublimeTmpl folder and open the file SublimeTmpl.sublime-settings. Save the file with the same file name under Packages\User. Delete everything except the variables that are custom to you. By the time you are finished, the file might look as simple as this (JSON format):
{
"attr": {
"author": "Chuck Norris" ,
"email": "chuck@kickbutt.com",
}
}
If you don't want the "link" and "hello" variables to show up, you should copy the (for example) python.tmpl file to Packages/User/SublimeTmpl/templates and remove those elements from it.
Contributors
Donate
FAQ
- SublimeTmpl not work after update the package.
Please open Preferences / Settings - User, remove “SublimeTmpl” from ignored_packages.
- Alert message Replace pattern None doesn't seem to work: unsupported operand type(s) for %: 'NoneType' and 'str'
Please restart Sublime Text and try again.
Source: https://github.com/kairyou/SublimeTmpl
Docs: 中文文档