aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-07-19 23:24:19 +0900
committerYehuda Katz <wycats@gmail.com>2009-07-19 23:24:19 +0900
commit45d41d8012c605f21de51e7018fa31e1d07776eb (patch)
tree21afefe5df997ee6abd3a62c0db4185bd7968bb6 /actionpack
parentb20d68446d2fe98d129385a17a3a4cdacd4b5025 (diff)
downloadrails-45d41d8012c605f21de51e7018fa31e1d07776eb.tar.gz
rails-45d41d8012c605f21de51e7018fa31e1d07776eb.tar.bz2
rails-45d41d8012c605f21de51e7018fa31e1d07776eb.zip
Add some simple examples for unconventional AMo and AP use
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/examples/very_simple.rb50
-rw-r--r--actionpack/examples/views/layouts/alt.html.erb1
-rw-r--r--actionpack/examples/views/layouts/kaigi.html.erb1
-rw-r--r--actionpack/examples/views/template.html.erb1
4 files changed, 53 insertions, 0 deletions
diff --git a/actionpack/examples/very_simple.rb b/actionpack/examples/very_simple.rb
new file mode 100644
index 0000000000..8d01cb39bd
--- /dev/null
+++ b/actionpack/examples/very_simple.rb
@@ -0,0 +1,50 @@
+$:.push "rails/activesupport/lib"
+$:.push "rails/actionpack/lib"
+
+require "action_controller"
+
+class Kaigi < ActionController::Http
+ include AbstractController::Callbacks
+ include ActionController::RackConvenience
+ include ActionController::Renderer
+ include ActionController::Layouts
+ include ActionView::Context
+
+ before_filter :set_name
+ append_view_path "views"
+
+ def _action_view
+ self
+ end
+
+ def controller
+ self
+ end
+
+ DEFAULT_LAYOUT = Object.new.tap {|l| def l.render(*) yield end }
+
+ def _render_template_from_controller(template, layout = DEFAULT_LAYOUT, options = {}, partial = false)
+ ret = template.render(self, {})
+ layout.render(self, {}) { ret }
+ end
+
+ def index
+ render :template => "template"
+ end
+
+ def alt
+ render :template => "template", :layout => "alt"
+ end
+
+ private
+ def set_name
+ @name = params[:name]
+ end
+end
+
+app = Rack::Builder.new do
+ map("/kaigi") { run Kaigi.action(:index) }
+ map("/kaigi/alt") { run Kaigi.action(:alt) }
+end.to_app
+
+Rack::Handler::Mongrel.run app, :Port => 3000 \ No newline at end of file
diff --git a/actionpack/examples/views/layouts/alt.html.erb b/actionpack/examples/views/layouts/alt.html.erb
new file mode 100644
index 0000000000..c4816337a6
--- /dev/null
+++ b/actionpack/examples/views/layouts/alt.html.erb
@@ -0,0 +1 @@
++ <%= yield %> + \ No newline at end of file
diff --git a/actionpack/examples/views/layouts/kaigi.html.erb b/actionpack/examples/views/layouts/kaigi.html.erb
new file mode 100644
index 0000000000..274607a96a
--- /dev/null
+++ b/actionpack/examples/views/layouts/kaigi.html.erb
@@ -0,0 +1 @@
+Hello <%= yield %> Goodbye \ No newline at end of file
diff --git a/actionpack/examples/views/template.html.erb b/actionpack/examples/views/template.html.erb
new file mode 100644
index 0000000000..3108e9ad70
--- /dev/null
+++ b/actionpack/examples/views/template.html.erb
@@ -0,0 +1 @@
+Hello <%= @name %> \ No newline at end of file