https://github.com/vovayatsyuk/sublime-magic-templates
Magically simple PHP templates
https://github.com/vovayatsyuk/sublime-magic-templates
magento2-generator sublime-text-3
Last synced: about 1 year ago
JSON representation
Magically simple PHP templates
- Host: GitHub
- URL: https://github.com/vovayatsyuk/sublime-magic-templates
- Owner: vovayatsyuk
- License: mit
- Created: 2018-08-01T21:07:33.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-02-25T13:48:25.000Z (over 1 year ago)
- Last Synced: 2025-03-26T22:11:43.759Z (over 1 year ago)
- Topics: magento2-generator, sublime-text-3
- Language: Python
- Size: 2.52 MB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ✨ MagicTemplates ✨
[](https://travis-ci.org/vovayatsyuk/sublime-magic-templates)
Tired to type the same boilerplate code for each new file? MagicTemplates plugin
automatically inserts autogenerated content for all ~~known~~ files. And it's
not just a static snippet, but a magically generated working code!
```php
# 1. You create a new `Menu.php` file in swissup/module-navigationpro/src/Model/ResourceModel/
# 2. MagicTemplates is doing its job:
∧_∧
(。・ω・。)つ━☆・*。
⊂ ノ ・゜+.
しーJ °。+ *´¨)
.· ´¸.·*´¨) ¸.·*¨)
(¸.·´ (¸.·’* ⛧
_init('swissup_navigationpro_menu', 'menu_id');
}
}
```
See? And that was a single example, while module supports [much](#templates)
[much](#snippets-beta) more!
## Installation
1. Run “Package Control: Install Package” command
2. Type `MagicTemplates` and press Enter
## Configuration
Open Sublime Preferences and add `mt-` trigger for xml files:
```
"auto_complete_triggers": [
[keep_original_triggers],
{"selector": "text.xml", "characters": "mt-"}
],
```
## Examples
### PHP Template

### PHP Snippets

### XML Template and Snippets

## How it works?
### Templates
When you create a file, plugin do the following things:
1. Searches for the closest `composer.json` file (This approach allows to work
with multiple projects in the same window)
2. Detects project type, autoload parameters, and other useful information
by its content
3. If the project type matches one of the known types, plugin searches for the
[template](https://github.com/vovayatsyuk/sublime-magic-templates/blob/master/templates/magento2/files.json)
to use. If found - contents is automatically generated and inserted into
the file.
- Here is a pretty simple template for
[Magento's Collection](https://github.com/vovayatsyuk/sublime-magic-templates/blob/master/templates/magento2/files/Model/ResourceModel/Entity/Collection.php.txt)
- Here is a little bigger template for
[Magento's Form](https://github.com/vovayatsyuk/sublime-magic-templates/blob/master/templates/magento2/files/view/adminhtml/ui_component/form.xml.txt)
### Snippets (beta)
Sublime's native snippets mechanism doesn't allow to filter out available
snippets depending on filename pattern. MagicTemplates plugin
[allows to create](https://github.com/vovayatsyuk/sublime-magic-templates/blob/master/templates/magento2/snippets.json)
such kind of dynamic snippets!
This feature allows to reduce the number of shown snippets for various files.
For example, when working with Magento's `layout.xml` file MagicTemplates will
never show you autocompletions written for `ui_component.xml` files.
Additionally, these snippets fully supports MagicTemplates variables which
allows to generate
[more](https://github.com/vovayatsyuk/sublime-magic-templates/blob/master/templates/magento2/snippets/view/base/layout/css.txt)
[code](https://github.com/vovayatsyuk/sublime-magic-templates/blob/master/templates/magento2/snippets/etc/di.xml/virtualType.txt)
that simply works.
## Known Applications
- ~~Laravel~~
- ~~Magento1~~
- Magento2
- And a few [templates](https://github.com/vovayatsyuk/sublime-magic-templates/blob/master/templates/php/files.json)
and [snippets](https://github.com/vovayatsyuk/sublime-magic-templates/blob/master/templates/php/snippets.json)
for unknown php applications