LiveReload for Sublime Text¶
Plugins api¶
- class PluginAPI.PluginClass[source]¶
Class for implementing your custom plug-ins, sublime_plugins compatible
Plug-ins implementing this reference should provide the following attributes:
- description (string) describing your plug-in
- title (string) naming your plug-in
- file_types (string) file_types which should trigger refresh for this plug-in
- addResource(req_path, blob, content_type='text/plain')[source]¶
- (string) req_path; browser path to file you want to serve. Ex: /yourfile.js
- (string/file) buffer; string or file instance to file you want to serve
- (string) content_type; Mime-type of file you want to serve
- onReceive(data, origin)[source]¶
Event handler which fires when browser plug-ins sends data - (string) data sent by browser - (string) origin of data
- refresh(filename, settings=None)[source]¶
Generic refresh command
- (string) filename; file to refresh (.css, .js, jpg ...)
- (object) settings; how to reload(entire page or just parts)
- sendCommand(command, settings, filename=False)[source]¶
- (instance) plug-in; instance
- (string) command; to trigger in livereload.js (refresh, info, or one of the plugins)
- (object) settings; additional data that gets passed to command (should be json parsable)
- (string) original name of file
Decorators:
- class LiveReload.LiveReload[source]¶
Bases: threading.Thread, server.SimpleCallbackServer.SimpleCallbackServer, server.SimpleWSServer.SimpleWSServer, server.SimpleResourceServer.SimpleResourceServer, server.LiveReloadAPI.LiveReloadAPI
Start the LiveReload, which exposes public api.
- LiveReload.http_callback(callback_f)[source]¶
Add http callback to plugin defined function. For example request to GET /callback/plugin_name/log_me would trigger log_me function in plugin
Example:
@LiveReload.http_callback def compiled(self, req): print req # urlparse object return "cool" #to http client
- LiveReload.websocket_callback(callback_f)[source]¶
Add websocket callback to plugin defined function. For example on function call in browser LiveReload.SM2.plugin_name.definedfunction(data) would trigger definedfunction function in plugin or vice verse. Shortly you can call client functions from the server and server functions from client. Everything is JSON encoded by default.
Example:
@LiveReload.websocket_callback def compiled(self, json): print json # json object return "cool" #to http client {msg: "cool"}