mattetti / lyndon forked from defunkt/lyndon
- Source
- Commits
- Network (5)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
commit a3fa1f69053d2abe0e075f3781d9487d3eb38be6
tree 303decf0dae1a9e63d4a6ef32af97079af1e7a2e
parent f6f94423918fb86cbcb205eff271d18faf032964
tree 303decf0dae1a9e63d4a6ef32af97079af1e7a2e
parent f6f94423918fb86cbcb205eff271d18faf032964
lyndon /
| name | age | message | |
|---|---|---|---|
| |
LICENSE | Thu Jun 18 21:00:44 -0700 2009 | |
| |
README.markdown | Wed Aug 26 03:08:32 -0700 2009 | |
| |
Rakefile | ||
| |
bin/ | ||
| |
examples/ | Wed Aug 26 03:08:32 -0700 2009 | |
| |
lib/ |
README.markdown
Lyndon
Lyndon is like Johnson. But for MacRuby. And with JavaScriptCore.
Here It Goes
$ rip install git://github.com/defunkt/lyndon.git
Successfully installed lyndon (41548d2)
$ lyndon
js> 1 + 1
=> 2
js> function name() { return "lyndon!" }
=> undefined
js> name
=> function name() { return "lyndon!" }
js> name()
=> "lyndon!"
js> Ruby.puts('Ruby, I presume.')
Ruby, I presume.
=> undefined
js> Ruby.File_read('hi.js')
=> "// this is hi.js\n"
Stuff like that.
Oh, the DOM
$ lyndon test.html
js> Lyndon.require('jquery.min.js')
=> true
js> jQuery('#hi').html()
=> "Hello."
js> jQuery('#hi').html('Hi.')
=> [object Object]
js> jQuery('#hi').html()
=> "Hi."
=> "[object HTMLBodyElement]"
js> document.body.innerHTML
=> "\n <h1 id=\"hi\">Hi.</h1>\n \n\n"
HTML with JavaScript
$ cat examples/index.html | lyndon
<html><head>
<title>It worked!</title>
</head><body>
<div id="content">
<div id="hi">Hello world!</div></div>
</body></html>
Note that the <div id="hi">Hello world!</div></div> does not exist
in examples/index.html - it's added at runtime by
JavaScript. JavaScript that strips itself out and changes the
<title>.
Seriously.
With Ruby
If you want:
$ macirb
>> require 'lyndon'
=> true
>> Lyndon.eval('1 + 1')
=> 2
>> r = Lyndon::Runtime.new
=> ##-<Lyndon::Runtime:...>
>> r.eval('var name = "chris"')
=> undefined
>> r.eval('name')
=> "chris"
That's basically it.
Chris Wanstrath // chris@ozmm.org

