These are chat archives for opal/opal

5th
Jan 2015
Jamie Gaskins
@jgaskins
Jan 05 2015 00:06
@cantonic I've been thinking of writing a gon wrapper myself. It's just a global hash, so it should be pretty simple.
Can Edremitoglu
@cantonic
Jan 05 2015 04:03
@jgaskins
ruby gon = Native(`window`)[:gon]did the trick for me
Jamie Gaskins
@jgaskins
Jan 05 2015 04:05
@cantonic The reason I was thinking about making a wrapper for it was so you could do something like Gon.foo
Can Edremitoglu
@cantonic
Jan 05 2015 04:05
makes sense
@jgaskins feel free to share the repo with me. maybe I can help
George
@georgeu2000
Jan 05 2015 23:38
Do I need to source the opal.js file in the HTML file? I believe it is quite large ~800K.
Adam Beynon
@adambeynon
Jan 05 2015 23:39
@georgeu2000 opal needs to be present to run any compiled code. The best practive is to require ‘opal’ somewhere inside your .rb file
George
@georgeu2000
Jan 05 2015 23:39
So, does that load ~800KB of javascript into the browser?
Adam Beynon
@adambeynon
Jan 05 2015 23:40
Last time I used opal.js directly it was about 200-300kb un-minified
800kb sounds like you have the compiler included in that as well
where is this opal.js file from?
George
@georgeu2000
Jan 05 2015 23:41
I think I compiled it myself...worked on it a few months ago so I forgot...
Adam Beynon
@adambeynon
Jan 05 2015 23:42
Ah ok.
We do supply pre compiled files
but, I still recommend just requiring the runtime into your app/code to make sure its up to date with the compiler version
George
@georgeu2000
Jan 05 2015 23:43
So 200-300kb is the size of the Opal code that is sent to the browser?
Elia Schito
@elia
Jan 05 2015 23:45
georgeu2000, yes, unless you use the minified or minified+gz version which will be under 40k
George
@georgeu2000
Jan 05 2015 23:46
OK, got it. Thanks. I thought 800kb meant I was doing something wrong.
@adambeynon - Thanks for the help!
Adam Beynon
@adambeynon
Jan 05 2015 23:50
@elia on a related note, I have made some changes to core lib to make it more “pick and choose” - can make corelib very light weight - I needed it for a site that needs to be as small as possible
require "opal-mini"
will pop up a branch tomorrow (few quirks need to be fixed before merging into master)
Elia Schito
@elia
Jan 05 2015 23:51
adambeynon, I count on it ;)
Adam Beynon
@adambeynon
Jan 05 2015 23:51
:smile:
Elia Schito
@elia
Jan 05 2015 23:52
and if you get a chance publish those webview + opal examples, I guess they'd be good for "marketing"
Andrew Havens
@andrewhavens
Jan 05 2015 23:52
haha, is it kind of the opal version of mruby? ;)
Elia Schito
@elia
Jan 05 2015 23:53
andrewhavens, exactly that, but less detached from the full version I guess :)
Andrew Havens
@andrewhavens
Jan 05 2015 23:53
that’s pretty cool
I really want to use Opal, but haven’t been able to integrate it in a project yet
I’m working on a CoffeeScript/Backbone project right now
I’m using a sort of HAML with CoffeeScript template compilation for JST templates right now…I’m curious…do you know of any Opal template libraries?
like a gem you can install which makes it so you can write ERB or HAML templates using Opal?
Adam Beynon
@adambeynon
Jan 05 2015 23:59
The opal gem supports compiling erb and we have opal-haml as well. Some docs on website but they need some TLC to cleanup