Permalink
Browse files

more README instructions

  • Loading branch information...
1 parent 8b1a46e commit 99d55e84c3b90a09b3c8873d9e8fa3f811d8964b @kristianmandrup committed Nov 22, 2012
Showing with 60 additions and 30 deletions.
  1. +30 −0 README.rdoc
  2. +2 −16 lib/apotomo.rb
  3. +12 −0 lib/apotomo/widget.rb
  4. +16 −14 lib/apotomo/widget_render_buffer.rb
View
@@ -73,6 +73,27 @@ And a Form widget within the TopBar namespace
create app/assets/javascripts/widgets/top_bar/form_widget.coffee
create app/assets/stylesheets/widgets/top_bar/form_widget.css
+Note that the widget generator supports the following templating engines:
+
+* erb
+* haml
+* slim
+
+=== Engines
+
+Apotomo can also be used with engines. In your engine, simply run the apotomo engine_setup generator.
+
+ $ rails g apotomo:engine_setup my_cool
+ create config/initializers/apotomo.rb
+
+This will add the following initialization code
+
+ Rails.application.config.after_initialize do
+ Apotomo::Widget.append_view_path MyCool::Engine.root + 'app/widgets'
+ end
+
+This instructs the Rails app hosting the engine to append this engine's widgets path to the global list of apotomo widget paths.
+
== Plug it in
You now tell your controller about the new widget.
@@ -406,6 +427,15 @@ Which will result in the statement:
Widgets.thang.toggleActive('action': ".item:first");
```
+== Render buffer
+
+A render buffer can be used for the views like this:
+
+ render_buffer do |b|
+ b.replace "##{widget_id}", :view => :display if invitation
+ b.replace "section#invite", :text => ""
+ end
+
== Testing
Apotomo comes with its own test case and assertions to <b>build rock-solid web components</b>.
View
@@ -21,26 +21,12 @@ def setup
end
require 'apotomo/widget'
+require 'apotomo/widget_render_buffer'
require 'apotomo/engine'
require 'apotomo/cell/rendering'
require 'apotomo/widget_shortcuts'
require 'apotomo/rails/controller_methods'
require 'apotomo/javascript_generator'
require 'apotomo/test_case' if Rails.env == "test"
-Apotomo.js_framework = :jquery ### DISCUSS: move to rails.rb
-
-# https://github.com/apotonick/apotomo/issues/72
-
-# USAGE
-# render_buffer do |b|
-# b.replace "##{widget_id}", :view => :display if invitation
-# b.replace "section#invite", :text => ""
-# end
-
-# where to better put this?
-def render_buffer
- buffer = WidgetRenderBuffer.new self
- yield buffer
- buffer.to_s
-end
+Apotomo.js_framework = :jquery ### DISCUSS: move to rails.rb
View
@@ -86,6 +86,18 @@ def initialize(parent, id, options={})
run_hook :after_initialize, self
end
+
+ # See # https://github.com/apotonick/apotomo/issues/72
+
+ # render_buffer do |b|
+ # b.replace "##{widget_id}", :view => :display if invitation
+ # b.replace "section#invite", :text => ""
+ # end
+ def render_buffer
+ buffer = Apotomo::WidgetRenderBuffer.new self
+ yield buffer
+ buffer.to_s
+ end
def parent_controller
# i hope we'll get rid of any parent_controller dependency, soon.
@@ -1,18 +1,20 @@
-class WidgetRenderBuffer
- def initialize w
- @widget = w
- @buffer = ""
- end
+module Apotomo
+ class WidgetRenderBuffer
+ def initialize w
+ @widget = w
+ @buffer = ""
+ end
- def replace *args
- @buffer << @widget.replace(*args)
- end
+ def replace *args
+ @buffer << @widget.replace(*args)
+ end
- def render *args
- @buffer << @widget.render(@args)
- end
+ def render *args
+ @buffer << @widget.render(@args)
+ end
- def to_s
- @buffer
+ def to_s
+ @buffer
+ end
end
-end
+end

0 comments on commit 99d55e8

Please sign in to comment.