Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bf51185f4818
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 83ecf31be2ce
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Sep 3, 2015

  1. Copy the full SHA
    37da908 View commit details

Commits on Sep 12, 2015

  1. Merge pull request #1093 from gabrielrios/inline-ruby

    [Docs] Adding instructions on how to use opal-parser.js
    elia committed Sep 12, 2015
    Copy the full SHA
    83ecf31 View commit details
Showing with 32 additions and 0 deletions.
  1. +32 −0 README.md
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -86,6 +86,38 @@ File.write 'app.js', builder.to_s
```


### Compiling Ruby code from HTML (or Using it as you would with Inline Javascript)

Opal-parser allows you to *eval* Ruby code directly from your HTML
files without needing any other building process

So you can create a file like the one below, and start writing ruby for
your web applications.


```html
<!DOCTYPE html>
<html>
<head>
<script src="http://cdn.opalrb.org/opal/current/opal.js"></script>
<script src="http://cdn.opalrb.org/opal/current/opal-parser.js"></script>
<script type="text/javascript">Opal.load('opal-parser')</script>
<script type="text/ruby">
puts "hi"
</script>
</head>
<body>
</body>
</html>
```

Just open this page and check the JavaScript console.

**NOTE**: Although this is possible, this is not really recommended for
production and should only be used as a quick way to getting you hands
on opal


## Running tests

First, install dependencies: