Notepad++에서 .haml을 .html로 변환하시겠습니까?

Notepad++에서 .haml을 .html로 변환하시겠습니까?

.haml 파일을 업데이트하고 저장할 때마다 "haml [filename.haml] [filename.html]" 콘솔 라인을 자동으로 실행하도록 Notepad++를 설정하려면 어떻게 해야 합니까?

답변1

Python 스크립트 플러그인을 사용하여 이 작업을 수행할 수 있습니다. 다음과 같이 새 스크립트를 추가하면 됩니다.

notepad.clearCallbacks([NOTIFICATION.FILESAVED])

# Define the function to call just after the file is saved
def runHaml(args):
    filename = notepad.getBufferFilename(args["bufferID"])
    if filename[-5:] == '.haml':
        cmd = r'cmd /c C:\path\to\haml "{0}" "{1}.html"'.format(filename, filename[:-5])
        console.write(cmd + "\n")
        console.run(cmd)


# ... and register the callback 
notepad.callback(runHaml, [NOTIFICATION.FILESAVED])

이것을 start.py에 추가하면 시작 시 자동으로 실행되도록 할 수 있습니다(Python 스크립트의 구성도 "ATSTARTUP"으로 변경).

답변2

다음과 같은 것을 사용하는 것은 어떻습니까?감시자스크립트?

다음과 같은 것 :

watch( '(.*)\.haml' ) do |md|
  system("haml #{md[0]} #{md[1]}.html")
end

소스 haml이 변경될 때마다 HTML 파일을 자동으로 다시 컴파일해야 합니다.

관련 정보