teacup-rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +45 -2
- data/lib/teacup-rails.rb +3 -1
- data/lib/teacup-rails/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
![teacup](https://raw.github.com/goodeggs/teacup/master/docs/teacup.jpg)
|
2
|
+
|
1
3
|
# Teacup::Rails
|
2
4
|
|
3
|
-
|
5
|
+
Teacup::Rails makes [Teacup](http://goodeggs.github.com/teacup) native CoffeeScript templates
|
6
|
+
available to the Rails asset pipeline.
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
@@ -16,9 +19,49 @@ Or install it yourself as:
|
|
16
19
|
|
17
20
|
$ gem install teacup-rails
|
18
21
|
|
22
|
+
Make Teacup available to your JavaScript application by requiring it in `app/assets/javascripts/application.js`
|
23
|
+
before your application files.
|
24
|
+
|
25
|
+
``` javascript
|
26
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
27
|
+
// listed below.
|
28
|
+
|
29
|
+
//= require jquery
|
30
|
+
//= require jquery_ujs
|
31
|
+
//= require teacup
|
32
|
+
//= require_tree .
|
33
|
+
```
|
34
|
+
|
19
35
|
## Usage
|
20
36
|
|
21
|
-
|
37
|
+
Teacup exports one reference to the global scope as `window.teacup`. Import the tags you need to render your view.
|
38
|
+
|
39
|
+
```coffeescript
|
40
|
+
{renderable, h1, table, tr, th, td, a} = teacup
|
41
|
+
template = renderable ({posts})->
|
42
|
+
h1 'Listing posts'
|
43
|
+
table "#posts-table", ->
|
44
|
+
tr ->
|
45
|
+
th 'Title'
|
46
|
+
th 'Content'
|
47
|
+
for post in posts
|
48
|
+
tr '.post-row', ->
|
49
|
+
td post.title
|
50
|
+
td post.content
|
51
|
+
a href: '#/new', 'New Post'
|
52
|
+
|
53
|
+
class IndexView extends Backbone.View
|
54
|
+
template: template
|
55
|
+
|
56
|
+
constructor: ({@posts}) ->
|
57
|
+
super()
|
58
|
+
|
59
|
+
render: =>
|
60
|
+
@$el.html @template(posts: @posts.toJSON())
|
61
|
+
@
|
62
|
+
```
|
63
|
+
|
64
|
+
See [Teacup Examples](http://goodeggs.github.com/teacup/#examples) for more usage examples.
|
22
65
|
|
23
66
|
## Contributing
|
24
67
|
|
data/lib/teacup-rails.rb
CHANGED
data/lib/teacup-rails/version.rb
CHANGED