File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,16 @@ def eval(str)
8
8
code = Opal . compile str
9
9
`eval(#{ code } )`
10
10
end
11
+
12
+ def require_remote url
13
+ source = %x{
14
+ var r = new XMLHttpRequest();
15
+ r.open("GET", url, false);
16
+ r.send('');
17
+ return r.responseText;
18
+ }
19
+ eval source
20
+ end
11
21
end
12
22
13
23
%x{
@@ -23,11 +33,13 @@ def eval(str)
23
33
};
24
34
25
35
function run_ruby_scripts() {
26
- var tags = document.getElementsByTagName('script');
36
+ var tag, tags = document.getElementsByTagName('script');
27
37
28
38
for (var i = 0, len = tags.length; i < len; i++) {
29
- if (tags[i].type === "text/ruby") {
30
- Opal.eval(tags[i].innerHTML);
39
+ tag = tags[i];
40
+ if (tag.type === "text/ruby") {
41
+ if (tag.src) Opal.Kernel.$require_remote(tag.src);
42
+ if (tag.innerHTML) Opal.Kernel.$eval(tag.innerHTML);
31
43
}
32
44
}
33
45
}
You can’t perform that action at this time.
0 commit comments