Skip to content
This repository
Newer
Older
100644 71 lines (45 sloc) 3.097 kb
55afa0cc »
2010-05-03 Add framework docs
1 # Barista #
02b7a2dc »
2010-04-24 Add more barista stuff
2
3 Barista is very, very similar to [bistro\_car](http://github.com/jnicklas/bistro_car) (infact, credit where credit is due - it shares similar
4 code / is almost a fork).
5
6 The main difference being, it lets you use coffee as you would javascript. Simply put, Write coffee
64971654 »
2010-04-27 Add Barista.configure, misc doc changes
7 and place it in `app/coffeescripts` and Barista will automatically serve it as if it was placed in `public/javascripts`
02b7a2dc »
2010-04-24 Add more barista stuff
8
64971654 »
2010-04-27 Add Barista.configure, misc doc changes
9 That is, `app/coffeescripts/demo.coffee` will work for `/javascripts/demo.js`. Even better (and more importantly
02b7a2dc »
2010-04-24 Add more barista stuff
10 for me), it provides `Barista.compile_all!` which takes all coffee files and compiles them into `public/javascripts`.
11
12 If you're using Jammit, this means you can simple run a rake task (`rake barista:brew` before running jammit) and
13 your coffeescripts will be automatically provided, ready for bundling.
14
762266fc »
2010-04-24 More docs
15 To add to your project, simply add:
16
55afa0cc »
2010-05-03 Add framework docs
17 gem 'barista', '>= 0.2.0'
762266fc »
2010-04-24 More docs
18
19 To your Gemfile and run bundle install.
20
21 As you place .coffee files in app/scripts, it will automatically handle them for you.
22
f6d92739 »
2010-04-25 More docs
23 Please note that for Jammit compatibility etc, by default in test and dev mode it will
24 automatically compile all coffeescripts that have changed before rendering the page.
25
64971654 »
2010-04-27 Add Barista.configure, misc doc changes
26 Barista require rails 3+ (but patches for Rails 2 will be accepted.)
27
55afa0cc »
2010-05-03 Add framework docs
28 ## Frameworks ##
29
30 One of the other main features Barista adds (over bistro\_car) is frameworks similar
31 to Compass. The idea being, you add coffeescripts at runtime from gems etc. To do this,
32 in your gem just have a coffeescript directory and then in you gem add the following code:
33
34 Barista::Framework.register 'name', 'full-path-to-directory' if defined?(Barista::Framework)
35
36 For an example of this in practice, check out [bhm-google-maps](http://github.com/YouthTree/bhm-google-maps)
37 or, the currently-in-development, [shuriken](http://github.com/Sutto/shuriken).
38
85060b17 »
2010-05-03 Bump version, allow you to change prefixes for frameworks
39 In your `Barista.configure` block, you can also configure on a per-application basis the output directory
40 for individual frameworks (e.g. put shuriken into vendor/shuriken, bhm-google-maps into vendor/bhm-google-maps):
41
42 Barista.configure do |config|
43 config.change_output_prefix! 'shuriken', 'vendor/shuriken'
44 config.change_output_prefix! 'bhm-google-maps', 'vendor/bhm-google-maps'
45 end
46
47 Alternatively, to prefix all, you can use `Barista.each_framework` (if you pass true, it includes the 'default' framework
48 which is your application root).
49
50 Barista.configure do |config|
51 config.each_framework do |framework|
52 config.change_output_prefix! framework.name, "vendor/#{framework.name}"
53 end
54 end
55
64971654 »
2010-04-27 Add Barista.configure, misc doc changes
56 ## Configuration ##
57
58 Please note that barista lets you configure several options. To do this,
59 it's as simple as setting up an initializer with:
60
3442ea52 »
2010-04-27 Add the generator
61 rails generate barista_install
64971654 »
2010-04-27 Add Barista.configure, misc doc changes
62
63 Then editing `config/initializers/barista_config.rb`.
64
65 Currently available options are:
66
67 * root - the folder path to read coffeescripts from, defaults to app/coffeescripts
68 * output\_root - the folder to write them into, defautls to public/javascripts.
69 * no\_wrap - stop coffee from automatically wrapping JS in a closure.
70
Something went wrong with that request. Please try again.