Home Download Buy Blog Forum Support

File Templates

File Templates

Postby apocalip on Tue Feb 21, 2012 12:24 am

Hey,

i've just finished my first Version of SublimeFileTemplates.
Basically it enables you to create Files with Snippet Content in one swoop.

Check out the GitHub Page or this Video to learn more:

https://github.com/mneuhaus/SublimeFileTemplates

http://www.youtube.com/watch?v=M4isYen7_Z4
apocalip
 
Posts: 4
Joined: Fri Feb 17, 2012 5:58 pm

Re: File Templates

Postby apocalip on Tue Feb 21, 2012 2:55 pm

Now available through Package Control :)
apocalip
 
Posts: 4
Joined: Fri Feb 17, 2012 5:58 pm

Re: File Templates

Postby atomi on Thu Feb 23, 2012 12:04 am

I saw this the other day.

I wondered why not just bind ctrl+n a show_quick_panel command that lists and executes new template commands.
When you select the

For example: new_templates.py
Code: Select all
class NewHtmlCommand(sublime_plugin.WindowCommand):
    def run(self):
        v = self.window.new_file()
        v.settings().set('default_extension', 'html')
        v.set_syntax_file('Packages/HTML/HTML.tmLanguage')
        template = """<!doctype html>
<html>
<head>
    <title>$1</title>
</head>
<body>
$0
</body>
</html>"""
        v.run_command("insert_snippet", {"contents": template})

class NewMarkdownCommand(sublime_plugin.WindowCommand):
    def run(self):
        v = self.window.new_file()
        v.settings().set('default_extension', 'md')
        v.set_syntax_file('Packages/Markdown/Markdown.tmLanguage')
        template = """---
layout: $1
title: $2
---
#$2
$0
"""
        v.run_command("insert_snippet", {"contents": template})
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: File Templates

Postby apocalip on Thu Feb 23, 2012 10:44 am

My Plugin does a few more things:

you can predefine the filename based on a specific need. For example, if you Controllers all have be named MyController.php you can define an argument to enter the controller's name and then use this argument in the filename: "$nameController.php" and then you can use this argument inside the template as well.
Additionally you can specify a predefined path for files. In case of the example above you could pre-define the path to be "Classes/Controllers/". So this file will be easily created inside that Folder by default.

i guess you could do all that inside your own custom commands, but my package bundles this behavior neatly into a plugin so anyone can just create some file-templates inside their packages.

greetings marc
apocalip
 
Posts: 4
Joined: Fri Feb 17, 2012 5:58 pm

Re: File Templates

Postby DrDran on Tue May 08, 2012 8:38 pm

HI, I'll try your plugin, but on my sublime text 2 rel. 2195 the plugin didn't create file or directory, is possible that changes in the API breaks the program?
DrDran
 
Posts: 17
Joined: Sat Aug 13, 2011 7:33 pm
Location: Imola

Re: File Templates

Postby raguay on Mon Jun 18, 2012 5:53 am

Hi,

The plugin creates the file, but puts nothing inside. The console shows the contents of my template with the variables still there. Not sure what I am doing wrong. I am using Build 2181. Also, I can not hear anything in the video. I am running on a Windows 7 system. Have not tried it under Linux yet.
raguay
 
Posts: 4
Joined: Mon Jun 18, 2012 5:49 am

Re: File Templates

Postby Coldblackice on Fri Jun 29, 2012 4:59 pm

Brilliant! Just what I was looking for, and am excited to try this out immediately! Thanks!
Coldblackice
 
Posts: 9
Joined: Sun Jun 17, 2012 9:08 am

Re: File Templates

Postby postman on Tue Jul 10, 2012 11:58 am

2 apocalip

Can you add option, to create several files from one template?
like arguments:
Code: Select all
<files>
    <file1>$name.php</file1>
    <file2>$name.bro.php</file2>
</files>

<arguments>
    <name>Name:</name>
</arguments>


It will be very useful.
Thanks.
postman
 
Posts: 2
Joined: Mon Jul 09, 2012 10:26 am

Re: File Templates

Postby jasimud on Tue Sep 25, 2012 4:35 am

Hey, i'm trying to make a template for latex.
I guess i've to make a Latex.file-template file in /Templates. But when i open the command palette and select Create New Template i really don't understand what is the idea of that file that pop's up. Could you help me?

Thanks
jasimud
 
Posts: 1
Joined: Tue Sep 25, 2012 4:32 am

Re: File Templates

Postby lawlist on Fri Apr 05, 2013 12:29 am

https://github.com/lawlist/ST2-plugin-Insert-File-Here

This is an insert file here plugin ST2 (OSX Mountain Lion), which is a modification of the plugin developed by the original poster.
lawlist
 
Posts: 54
Joined: Thu Feb 21, 2013 6:47 pm


Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 8 guests

cron