== RDoc Lets say we have a RDoc document called 'test.rdoc' containing: = Example This is an example of RDoc rendering. We can convert rdoc documents to html easily via the univeral +render+ function. html = Malt.render(:file=>'tmp/test.rdoc') html.assert.include?('

Example

') Malt recognizes the type of file by the '.rdoc' extension and renders it using the default redering engine (in this case RDoc itself). By default the engine renders to HTML, so we did not need to specify the output :format option to the +render+ method. If we have a file that has a different extension, but is in fact an RDoc document, we can inform Malt. Lets say we have an RDoc document called 'test.txt' containing: = Example This is an example of RDoc rendering. We can inform Malt as the actual type using the `:type` option. html = Malt.render(:file=>'tmp/test.txt', :type=>:rdoc) html.assert.include?('

Example

') Alternately we can use the object-oriented interface. Again, lets say we have an RDoc document called 'test.rdoc' containing ... = Example This is an example of RDOC rendering. Then we can use the `Malt.file` method to instantiate an RDoc object. rdoc = Malt.file('tmp/test.rdoc') We will notice that the output is an instance of Malt::Formats::HTML. rdoc.class.assert == Malt::Format::RDoc While we could have used `Malt::Formats::RDoc.new` to create the object directly, Malt provides the #file, as well as #text, methods for convience. We can convert the rdoc to html with the #to_html method. html = rdoc.to_html Again notice that the output is an instance of Malt::Format::HTML. html.class.assert == Malt::Format::HTML And that by calling #to_s we can get the rendered HTML document. html.to_s.assert.include?('

Example

') We can convert rdoc documents to html very easily. rdoc = Malt.file('tmp/test.rdoc') html = rdoc.to_html First we will notice that the output is an instance of Malt::Format::HTML. html.class.assert == Malt::Format::HTML And that by calling #to_s we can get the rendered HTML document. html.to_s.assert.include?('

Example

') Or we can convert the RDoc document directly to HTML via the #html method. out = rdoc.html out.assert.include?('

Example

')