-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtpl.py
33 lines (28 loc) · 1.19 KB
/
tpl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
'''
tpl plugin core code
~~~~~~~~~
:copyright: (c) 2015 by fewspider([email protected]).
:license: BSD, see LICENSE for more details.
'''
import sublime, sublime_plugin, subprocess
class TplCommand(sublime_plugin.TextCommand):
def run(self, edit):
dct = self.view.window().extract_variables()
file_extension = dct.get('file_extension', '')
file_path = dct.get('file', '')
settings = sublime.load_settings('Tpl.sublime-settings')
node_path = settings.get('node_path', '')
tpl_path = settings.get('tpl_path', '')
message = ''
if file_extension == 'html':
message = subprocess.check_output([node_path, tpl_path, file_path], universal_newlines=True)
else:
message = 'invalidate file extension:%s' % file_extension
self.show_console_panel(edit, message)
def show_console_panel(self, edit, message):
pt = self.view.window().get_output_panel('console_panel')
pt.set_read_only(False)
pt.insert(edit, 0, message)
pt.set_read_only(True)
self.view.window().run_command('show_panel', {'panel': 'output.console_panel'})