Sha256: 15a7f49aa43850bb045336f6bd2b44c3365c1e77887dbde4f611b4f7165a088f

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

# Install

## Use Ovto with static files

```
$ gem i ovto
$ ovto new myapp --static
```

## Use Ovto with Sinatra

```
$ gem i ovto
$ ovto new myapp --sinatra
```

## Install Ovto into Rails apps

Edit `Gemfile`

```rb
gem 'opal-rails'
gem 'ovto'
```

Run `bundle install`

Remove `app/assets/javascripts/application.js`

Create `app/assets/javascripts/application.js.rb`

```rb
require 'opal'
require 'rails-ujs'
require 'activestorage'
require 'turbolinks'
require_tree '.'
```

Create `app/assets/javascripts/foo.js.rb` (file name is arbitrary)

```rb
require 'ovto'

class Foo < Ovto::App
  class State < Ovto::State
  end

  class Actions < Ovto::Actions
  end

  class MainComponent < Ovto::Component
    def render(state:)
      o 'h1', "HELLO"
    end
  end
end
```

Edit `app/views/<some controller/<some view>.html.erb`

```
<div id='foo-app'></div>
<%= opal_tag do %>
  Foo.run(id: 'foo-app')
<% end %>
```

This should render `HELLO` in the browser.

You also need to edit config/environments/production.rb like this before deploy it to production.

```rb
    #config.assets.js_compressor = :uglifier
    config.assets.js_compressor = Uglifier.new(harmony: true)
```

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ovto-0.7.0 book/guides/install.md
ovto-0.6.2 book/guides/install.md
ovto-0.6.1 book/guides/install.md
ovto-0.6.0 book/guides/install.md
ovto-0.6.0.rc1 book/guides/install.md
ovto-0.5.0 book/guides/install.md