From 5adca53156589896b223213649daf74879882e6e Mon Sep 17 00:00:00 2001 From: Magnus Holm Date: Sat, 7 Mar 2009 23:23:32 +0100 Subject: [PATCH] Added some documentation of Camping::Views --- lib/camping-unabridged.rb | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/lib/camping-unabridged.rb b/lib/camping-unabridged.rb index 2520f96..c559497 100644 --- a/lib/camping-unabridged.rb +++ b/lib/camping-unabridged.rb @@ -878,14 +878,41 @@ def method_missing(m, c, *a) end end - # TODO: More examples. - # Views is an empty module for storing methods which create HTML. The HTML is described - # using the Markaby language. + # Views is an empty module for storing methods which create HTML. The HTML + # is described using the Markaby language. + # + # == Defining and calling templates + # + # Templates are simply Ruby methods with Markaby inside: + # + # module Blog::Views + # def index + # p "Welcome to my blog" + # end + # + # def show + # h1 @post.title + # self << @post.content + # end + # end + # + # In your controllers you just call +render :template_name+ which will + # invoke the template. The views and controllers will share instance + # variables (as you can see above). # # == Using the layout method # - # If your Views module has a layout method defined, it will be called with a block - # which will insert content from your view. + # If your Views module has a layout method defined, it will be + # called with a block which will insert content from your view: + # + # module Blog::Views + # def layout + # html do + # head { title "My Blog "} + # body { self << yield } + # end + # end + # end module Views; include X, Helpers end # TODO: Migrations