All these work fine, but you should make sure to use what??™s best suited for your current needs.
Using a too-powerful rendering solution is likely to make things harder on your users and
designers.
Finishing CoMpoSe
After a detour through content handling, it??™s finally time to finish the CoMpoSe application.
The solution to how the application will handle content rendering will use many of the techniques
already seen. There will also be support for generating intermediate content in another
format, through several runs of the XSLT style sheet transformer. In that way, you can define
much of the content in the same way, and then you could add provisions for outputting other
data as the outermost layer.
We??™ll begin by taking a look at the helper classes that will handle rendering. These classes
will live in the lib directory, and it??™s important to remember that they won??™t be reloaded when
modified, so you should always restart the web server when changing any of these files.
Rendering Engine
The main system that collects all the different methods is found in the file
lib/render_engine.rb and should look like this:
require 'xslt_transformer'
class RenderEngine
include Singleton
def render article, controller = nil
layout = article.layout || article.path.layout
options = { :title => article.subject }
current = self.send :"render_content_#{article.content_type.
name.downcase}", article.content, options, controller
if layout
for style in layout.
Pages:
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249