AdvancedNewFile icon indicating copy to clipboard operation
AdvancedNewFile copied to clipboard

file templates not working

Open victorwpbastos opened this issue 9 years ago • 10 comments

I have the following configuration:

{
    "file_templates": {
        "js": [
            "Packages/User/view.sublime-snippet"
        ]
    }
}

but when I create new js files, the content is not being inserted as expected. Is this a bug only happeging on Windows? I'm using Windows 7 x86.

victorwpbastos avatar May 28 '15 06:05 victorwpbastos

Hi @victorwpbastos, sorry for the delay, do you have "shell_input" set to true?

skuroda avatar Jun 03 '15 23:06 skuroda

Yes.

victorwpbastos avatar Jun 04 '15 16:06 victorwpbastos

Ah okay, that's why. Though I should have been a little smarter about doing it. If there are multiples paths specified (via curly brace expansion) I turn off the template functionality as the prompts would not work out very well. However, I should have kept it on if there is only one specified file, or if there is only 1 entry in the template. Thank you for the information.

skuroda avatar Jun 04 '15 19:06 skuroda

Even without shell_input the file_templates doesn't work.

victorwpbastos avatar Jun 04 '15 20:06 victorwpbastos

Are there any errors in the ST log with shell_input set to false?

skuroda avatar Jun 08 '15 22:06 skuroda

Yes:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 208, in on_load
    callback.on_load(v)
  File "advanced_new_file.commands.new_file_command in C:\Users\vbastos\AppData\Roaming\Sublime Text 3\Installed Packages\AdvancedNewFile.sublime-package", line 155, in on_load
  File "advanced_new_file.commands.new_file_command in C:\Users\vbastos\AppData\Roaming\Sublime Text 3\Installed Packages\AdvancedNewFile.sublime-package", line 179, in get_snippet_from_file
  File "./xml/etree/ElementTree.py", line 1356, in XML
TypeError: 'NoneType' does not support the buffer interface

victorwpbastos avatar Jun 10 '15 15:06 victorwpbastos

Ah I see, so there might be a problem with the snippet file (or how I'm processing it). Can you post that?

skuroda avatar Jun 10 '15 17:06 skuroda

<snippet>
    <content><![CDATA[
var Marionette = require('marionette');

module.exports = Marionette.ItemView.extend({
    template: require('templates/${TM_FILEPATH/.*views\/(.+)\..+/$1/}.tpl')
});
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>view</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
</snippet>

victorwpbastos avatar Jun 10 '15 17:06 victorwpbastos

Works if I remove the regex part.

victorwpbastos avatar Jun 10 '15 19:06 victorwpbastos

Hi Victor, apologize for leaving this hanging. Anyways, I'll look into this a bit more soon. I know I use the "insert_snippet" command to work with the templates. My best guess is it's doing something odd with the regex. Thanks for the sample snippet. It should help in reproducing the issue! Thanks for using AdvancedNewFile.

skuroda avatar Jul 09 '15 01:07 skuroda