https://github.com/existentialmutt/russian_hill
Views for CableCar
https://github.com/existentialmutt/russian_hill
Last synced: over 1 year ago
JSON representation
Views for CableCar
- Host: GitHub
- URL: https://github.com/existentialmutt/russian_hill
- Owner: existentialmutt
- License: mit
- Created: 2021-07-03T02:09:22.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-03T17:19:01.000Z (about 5 years ago)
- Last Synced: 2025-04-14T09:22:08.881Z (over 1 year ago)
- Language: Ruby
- Size: 77.1 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# RussianHill
Jbuilder-like views for CableReady's cable_car. Registers a .cablecar template extension and cablecar MIME type for a dedicated view you can use to build up operations to send in a response by calling e.g. `operations.morph`

## Usage
Example code:
app/controllers/demos_controller.rb
```ruby
class DemosController < ApplicationController
def index
respond_to do |format|
format.html
format.cablecar { @message = "Hello World!"}
end
end
end
```
app/views/demos/index.cablecar
```
operations.morph(selector: "#message", html: @message)
operations.inner_html(selector: "#inner", html: "Hi inner!")
operations.outer_html(selector: "#outer", html: render(partial: "message", formats: :html))
```
app/views/demos/index.html.erb
```html
window
.mrujs
.fetch("/cable_car_views", {headers: {"Accept": "text/vnd.cablecar.json"}})
.then(response => response.json())
.then(j => {
CableReady.perform(j)
})
```
app/views/demos/_message.html.erb
```html
Hello Partial!
Here's some html
<%= @message %>
```
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'russian_hill'
```
And then execute:
```bash
$ bundle
```
Or install it yourself as:
```bash
$ gem install russian_hill
```
## Contributing
Contribution directions go here.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).