viperet / vscode-magento-wizard

Helps develop Magento 2 extensions using VSCode
36 stars 16 forks source link

Disable auto-generated content #27

Closed lfolco closed 3 years ago

lfolco commented 3 years ago

This is a great extension! Is it possible to disable the auto-generated content when you create new files thgouh? For example, creating a PHTML template file you get this:

<?php
/** @var \Vendor\Module\Block\Template $block */
?>

<div class="template">
    <h1><?=$block->getName()?></h1>
</div>

This is code that I always delete, every single time. Not sure how useful it is? Same goes for a lot of the XML templates.

I am more than happy to open a PR for this, but would rather not do it if you object to merging it.

Thanks!

viperet commented 3 years ago

@lfolco You are welcome to open PR to either improve templates to make them more useful or add an option to disable this feature.

viperet commented 3 years ago

@lfolco added option to disable auto templates. You can set glob pattern in the settings, and templates would be used only for files matching that pattern. Set it to empty string to disable templates.

lfolco commented 3 years ago

Would this mean that it would be an empty file then?

viperet commented 3 years ago

Right, empty file.

lfolco commented 3 years ago

Hmm... what I am suggesting is to make the contents of the template more useful. A lot of code is generated in the db_schema.xml template, for example, but what you really only need is the schema definition:

<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">

</schema>

Same goes for the the .phtml template:

<div class="template">
    <h1><?=$block->getName()?></h1>
</div>

Not sure anyone would actually use that snippet in their .phtml template.

I was going to open a PR to remove the extraneous content that is added in the templates, but retain the useful parts.