SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 242 | Next

Ola Bini

"Practical JRuby on Rails Web 2.0 Projects: Bringing Ruby on Rails to Java"

each do |k,v|
val = v.map{|ll| ''/>' }.join("\n")
content.gsub! "",val
end
content
end
def source_for io
case io
when IO: StreamSource.new(IOInputStream.new(io))
when String: StreamSource.new(StringReader.new(io))
else raise ArgumentError, "couldn't handle argument of type #{io.class}"
end
end
def input_source_for io
case io
when IO: InputSource.new(IOInputStream.new(io))
when String: InputSource.new(StringReader.new(io))
else raise ArgumentError, "couldn't handle argument of type #{io.class}"
end
end
The only strange part of these helpers is render_options, which allows you to add something
like to your XSLT output, which is replaced with the
corresponding data generated with the link strings. This isn??™t dynamic enough, but you see
how it would be possible to add any kind of content here. The options hash could contain
blocks that generate the correct strings when called, or something similar to that.
This is all there is to the rendering of content in CoMpoSe. As said before, you can do
almost anything with this code and add whatever kinds of features you??™d like, but this is the
basis for content rendering.
CHAPTER 8 ?–  CONTENT RENDERING 160
Content
You need a controller that??™s responsible for generating the content. It shouldn??™t be secured,
and you don??™t need any views for it either:
jruby script/generate controller compose default_render style
rm -rf app/views/compose
You need two different actions for this: one for regular rendering, and one for serving style
sheets.


Pages:
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254