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-rails
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: eef51691c5a6
Choose a base ref
...
head repository: opal/opal-rails
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 39461c5755a5
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Dec 6, 2014

  1. Whitespace

    elia committed Dec 6, 2014

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a6a17ce View commit details
  2. Add instructions about shared templates

    fixes #16
    elia committed Dec 6, 2014
    Copy the full SHA
    9d115fe View commit details

Commits on Dec 7, 2014

  1. Update rspec-rails

    elia committed Dec 7, 2014
    Copy the full SHA
    e560869 View commit details
  2. Bump beta version

    elia committed Dec 7, 2014
    Copy the full SHA
    39461c5 View commit details
Showing with 39 additions and 2 deletions.
  1. +37 −0 README.md
  2. +1 −1 lib/opal/rails/version.rb
  3. +1 −1 opal-rails.gemspec
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -132,6 +132,7 @@ Of course you need to require `haml-rails` separately since its presence is not
Element.find('.comments').effect(:fade_in)
end
end
```


@@ -156,6 +157,42 @@ Then visit `/opal_spec` from your app and **reload at will** or use the command
![1 examples, 0 failures](http://f.cl.ly/items/001n0V0g0u0v14160W2G/Schermata%2007-2456110%20alle%201.06.29%20am.png)


### Shared templates

As long as the templates are inside the sprockets/opal load path, then you should be able to just require them.

Let's say we have this template `app/views/shared/test.haml`:

```haml
.row
.col-sm-12
= @bar
```

We need to make sure Opal can see and compile that template. So we need to add the path to sprockets:

```ruby
# config/initializers/opal.rb
Rails.application.config.assets.paths << Rails.root.join('app', 'views', 'shared').to_s
```

Now, somewhere in `application.rb` you need to require that template, and you can just run it through `Template`:

```ruby
# app/assets/javascripts/application.rb
require 'opal'
require 'opal-haml'
require 'test'

@bar = "hello world"

template = Template['test']
template.render(self)
# => '<div class="row"><div class="col-sm-12">hello world</div></div>'
```



## License

© 2012-2014 Elia Schito
2 changes: 1 addition & 1 deletion lib/opal/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Opal
module Rails
VERSION = '0.7.0.beta1'
VERSION = '0.7.0.beta2'
end
end
2 changes: 1 addition & 1 deletion opal-rails.gemspec
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.add_dependency 'rails', '>= 3.2', '< 5.0'
s.add_dependency 'opal', '~> 0.7.0.beta1'
s.add_dependency 'opal-jquery', '~> 0.3.0.beta1'
s.add_dependency 'opal-rspec', '~> 0.4.0.beta3'
s.add_dependency 'opal-rspec', '~> 0.4.0.beta4'
s.add_dependency 'jquery-rails'
s.add_dependency 'opal-activesupport', '>= 0.0.5'