Skip to content

Commit

Permalink
add Side Bar menu; update Contributors; add Donate
Browse files Browse the repository at this point in the history
  • Loading branch information
kairyou committed May 9, 2017
1 parent 9a68bb6 commit deb4887
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 8 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ Now go to `Packages\SublimeTmpl` folder and open the file SublimeTmpl.sublime-se
If you don't want the `"link"` and `"hello"` variables to show up, you should copy the (for example) python.tmpl file to `Packages/User/SublimeTmpl/templates` and remove those elements from it.


Authors
Contributors
-------
* **Kairyou** ([Blog](http://www.fantxi.com/blog/) / [GitHub](https://github.com/kairyou))
* **Vfasky** ([Blog](http://vfasky.com) / [GitHub](https://github.com/vfasky))
* **Xu Cheng** ([Github](https://github.com/xu-cheng))
- [View Contributors](https://github.com/kairyou/SublimeTmpl/graphs/contributors)

### Donate
<span class="badge-paypal"><a href="https://www.paypal.me/kairyou" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>

FAQ
---
Expand Down
76 changes: 76 additions & 0 deletions Side Bar.sublime-menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[
{
"id": "sublimetmpl",
"caption": "New File (SublimeTmpl)",
"children":
[
{
"id": "html",
"caption": "HTML",
"command": "sublime_tmpl",
"args": {
"type": "html",
"paths": [],
}
},
{
"id": "js",
"caption": "Javascript",
"command": "sublime_tmpl",
"args": {
"type": "js",
"paths": [],
}
},
{
"id": "css",
"caption": "CSS",
"command": "sublime_tmpl",
"args": {
"type": "css",
"paths": [],
}
},
{
"id": "php",
"caption": "PHP",
"command": "sublime_tmpl",
"args": {
"type": "php",
"paths": [],
}
},
{
"id": "python",
"caption": "python",
"command": "sublime_tmpl",
"args": {
"type": "python",
"paths": [],
}
},
{
"id": "ruby",
"caption": "ruby",
"command": "sublime_tmpl",
"args": {
"type": "ruby",
"paths": [],
}
},
{"caption": "-"},
{
"id": "menu",
"command": "open_file",
"args": {"file": "${packages}/SublimeTmpl/Side Bar.sublime-menu"},
"caption": "Side Bar Menu – Default"
},
{
"id": "menu",
"command": "open_file",
"args": {"file": "${packages}/User/SublimeTmpl/Side Bar.sublime-menu"},
"caption": "Side Bar Menu – User"
}
]
}
]
11 changes: 7 additions & 4 deletions sublime-tmpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class SublimeTmplCommand(sublime_plugin.TextCommand):

def run(self, edit, type='html'):
def run(self, edit, type='html', paths = [None]):
view = self.view
opts = self.get_settings(type)
tmpl = self.get_code(type)
Expand All @@ -40,7 +40,7 @@ def run(self, edit, type='html'):
return False

# print(KEY_SYNTAX in opts)
self.tab = self.creat_tab(view)
self.tab = self.creat_tab(view, paths)

self.set_syntax(opts)
# sublime.set_timeout(lambda: self.set_syntax(opts), 1000)
Expand Down Expand Up @@ -130,14 +130,17 @@ def format_tag(self, code):
code = re.sub(r"(?<!\\)\${(?!\d)", '\${', code)
return code

def creat_tab(self, view):
def creat_tab(self, view, paths = [None]):
win = view.window()
# tab = win.open_file('/tmp/123')
tab = win.new_file()
# tab.set_name('untitled')
active = win.active_view()
active.settings().set('default_dir', paths[0])
return tab

def set_code(self, code):
tab = self.tab
# tab.set_name('untitled.' + self.type)
# insert codes
tab.run_command('insert_snippet', {'contents': code})

Expand Down

0 comments on commit deb4887

Please sign in to comment.