It would be great if I could convert LESS to CSS with a single command. http://lesscss.org/
EDIT: Looks like there is a simple windows command line app http://www.dotlesscss.org/. See documentation. So making a plugin should be very simple.
import sublime, sublime_plugin, subprocess, os
class CompileLessOnSave(sublime_plugin.EventListener):
def on_post_save(self, view):
if not view.scope_name(0).strip().endswith('source.css.less'):
return
if os.name == "nt":
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(('dotless.Compiler.exe','-m',view.file_name()),
stdin=subprocess.PIPE, stdout=subprocess.PIPE, startupinfo=startupinfo)
print('Compiled ' + view.file_name())
Reloading plugin C:\Users\robin\AppData\Roaming\Sublime Text 2\Packages\Less\SaveToCSS.py
Traceback (most recent call last):
File ".\sublime_plugin.py", line 29, in reload_plugin
File ".\SaveToCSS.py", line 6
if os.name == "nt":
^
IndentationError: unindent does not match any outer indentation levelfirefusion wrote:I get this error
- Code: Select all
Reloading plugin C:\Users\robin\AppData\Roaming\Sublime Text 2\Packages\Less\SaveToCSS.py
Traceback (most recent call last):
File ".\sublime_plugin.py", line 29, in reload_plugin
File ".\SaveToCSS.py", line 6
if os.name == "nt":
^
IndentationError: unindent does not match any outer indentation level
if not view.scope_name(0).strip().endswith('source.css.less'):
if not view.scope_name(0).strip().endswith('source.css.less'):
Traceback (most recent call last):
File ".\sublime_plugin.py", line 29, in reload_plugin
File ".\CompileLessOnSave.py", line 1, in <module>
class CompileLessOnSave(sublime_plugin.EventListener):
NameError: name 'sublime_plugin' is not definedimport sublime, sublime_plugin, subprocess, os
class CompileLessOnSave(sublime_plugin.EventListener):
...
Users browsing this forum: No registered users and 5 guests