Sha256: 76914d74656fadec929183c453326f5a69a6ada1771b8578012e5030cbc2bc4d

Contents?: true

Size: 999 Bytes

Versions: 1

Compression:

Stored size: 999 Bytes

Contents

LAYOUT = <<-HTML
<!DOCTYPE html>
<html>
<head><%= javascript_include_tag "application" %></head>
<body><%= yield %></body>
</html>
HTML

INDEX = <<-HTML
<script type="text/ruby">
raise 'pippo'
</script>
HTML

WITH_ASSIGNMENTS = File.read "#{__dir__}/assets/javascripts/with_assignments.js.rb"

class ApplicationController < ActionController::Base
  include Rails.application.routes.url_helpers
  layout 'application'
  self.view_paths = [ActionView::FixtureResolver.new(
    'layouts/application.html.erb'         => LAYOUT,
    'application/index.html.erb'           => INDEX,
    'application/with_assignments.js.opal' => WITH_ASSIGNMENTS,
  )]

  def index
  end

  def with_assignments
    object = Object.new
    def object.as_json options = {}
      {contents: 'json representation'}
    end

    @number_var = 1234
    @string_var = 'hello'
    @array_var  = [1,'a']
    @hash_var   = {a: 1, b: 2}
    @object_var = object

    render type: :js, locals: { local_var: 'i am local' }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-rails-0.9.1 test_apps/application_controller.rb