Skip to content

Commit 65c35de

Browse files
committed
Update README.md
prettier formatting for code
1 parent c7751b3 commit 65c35de

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

README.md

+16-14
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,29 @@ How do I use it?
1212

1313
The following example will create a `WebView` and expose a function to it:
1414

15-
@import 'MochaJSWebScriptingObject.js'
15+
```javascript
16+
@import 'MochaJSWebScriptingObject.js'
1617

17-
// Create a WebView
18+
// Create a WebView
1819

19-
var webView = WebView.new();
20+
var webView = WebView.new();
2021

21-
// Expose functions
22+
// Expose functions
2223

23-
var webScriptingObject = MochaJSWebScriptingObject({
24-
demo: function(){
25-
var app = [NSApplication sharedApplication];
26-
[app displayDialog:"This is being called from a WebView! Cool!" withTitle:"Alert"];
27-
}
28-
});
24+
var webScriptingObject = MochaJSWebScriptingObject({
25+
demo: function(){
26+
var app = [NSApplication sharedApplication];
27+
[app displayDialog:"This is being called from a WebView! Cool!" withTitle:"Alert"];
28+
}
29+
});
2930

30-
var windowScriptObject = webView.windowScriptObject();
31+
var windowScriptObject = webView.windowScriptObject();
3132

32-
windowScriptObject.setValue_forKey_(webScriptingObject, "exported");
33-
windowScriptObject.evaluateWebScript_("exported.demo();");
33+
windowScriptObject.setValue_forKey_(webScriptingObject, "exported");
34+
windowScriptObject.evaluateWebScript_("exported.demo();");
35+
````
3436

3537
How does it work?
3638
----------------
3739

38-
`MochaJSWebScriptingObject` leverages [Mocha's](https://github.com/logancollins/Mocha) methods for manipulating the Objective-C runtime. It creates an NSObject complying with the [`WebScripting`](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/WebKit/Protocols/WebScripting_Protocol/index.html) protocol and manages function exposure between CocoaScript -> Objective-C -> WebView.
40+
`MochaJSWebScriptingObject` leverages [Mocha's](https://github.com/logancollins/Mocha) methods for manipulating the Objective-C runtime. It creates an NSObject complying with the [`WebScripting`](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/WebKit/Protocols/WebScripting_Protocol/index.html) protocol and manages function exposure between CocoaScript -> Objective-C -> WebView.

0 commit comments

Comments
 (0)