ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Magic​Templates

by vovayatsyuk ST3

Magically simple PHP templates

Details

Installs

  • Total 33
  • Win 20
  • OS X 8
  • Linux 5
Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31
Windows 0 0 0 1 2 0 0 1 0 0 0 0 2 1 0 0 2 0 1 0 3 3 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OS X 1 0 0 1 3 0 0 0 3 0 1 0 1 0 0 0 0 0 0 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

✨ MagicTemplates ✨

Build Status

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!

# 1. You create a new `Menu.php` file in swissup/module-navigationpro/src/Model/ResourceModel/

# 2. MagicTemplates is doing its job:

 ∧_∧
(。・ω・。)つ━☆・*。
⊂   ノ    ・゜+.
しーJ   °。+ *´¨)
  .· ´¸.·*´¨) ¸.·*¨)
(¸.·´ (¸.·’* ⛧

<?php

namespace Swissup\Navigationpro\Model\ResourceModel;

use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class Menu extends AbstractDb
{
    /**
     * Model initialization
     *
     * @return void
     */
    protected function _construct()
    {
        $this->_init('swissup_navigationpro_menu', 'menu_id');
    }
}

See? And that was a single example, while module supports much much 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

Template for Magento2 resource model

PHP Snippets

Template and snippets for Magento2 plugin

XML Template and Snippets

Template and snippets for Magento2 form ui_component

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 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 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 code that simply works.

Known Applications

  • Laravel
  • Magento1
  • Magento2
  • And a few templates and snippets for unknown php applications