sublimetext2 - build haml to html with sublime -


i want build haml in sublime text 2 without switch iterm. build simple plugin sublime, this.

import os import sublime, sublime_plugin  class hamltohtmlcommand(sublime_plugin.textcommand):     def run(self,edit):         source = self.view.file_name()         filefullname = source.split('/')[-1]         filename = filefullname.split('.')[0]         target = "/".join(source.split('/')[0:-1])         com = "haml " + source + " > " + target + "/" + filename +'.html'         os.system(com)       def is_enabled(self):         return true 

but problem that, when build in sublime, target html file empty. example, "com" "haml /users/latpaw/login_register/login.haml /users/latpaw/login_register/login.html". if os.system(com) in python cli, right.
happens here

by way, don't know haml, @ first tried fix code. think can build haml directly st, going tools→build (⌥b). or create new build system tools→build systems→new build system. apparently have following variables use:

  • $file full path current file, e. g., c:\files\chapter1.txt.
  • $file_path directory of current file, e. g., c:\files.
  • $file_name name portion of current file, e. g., chapter1.txt.
  • $file_extension extension portion of current file, e. g., txt.
  • $file_base_name name portion of current file, e. g., document.
  • $packages full path packages folder.
  • $project full path current project file.
  • $project_path directory of current project file.
  • $project_name name portion of current project file.
  • $project_extension extension portion of current project file.
  • $project_base_name name portion of current project file.

apparently have issue path escaping. must have, me when tried, space somewhere in path of file. or know commands cat ~/sublime text/test not work well. can either:

  • cat ~/sublime\ text/test
  • cat ~/'sublime text/test'

i advise later , this:

com = "haml '" + source + "' > '" + target + "/" + filename +"'.html" 

ps: arguably, better solution add these single quotes directly when defining source, target , filename.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -