Class: Malt::Format::Builder

Inherits:
Abstract show all
Defined in:
lib/malt/formats/builder.rb

Overview

Builder is the format common to Builder, Markaby, Erector and Nokogiri’s Builder. Although there are some variant features between them, they all support the same general format. The format looks like a Markup format, but is in fact a templating system built out of Ruby code for creating XML/HTML documents.

To unite these different engines I have designated them a common file extension of ‘.rbml`.

Instance Attribute Summary

Attributes inherited from Abstract

#options

Instance Method Summary collapse

Methods inherited from Abstract

#default, #engine, engine, extensions, #extensions, #file, file_extension, #file_read, #file_type, #parse_type_from_data, #refile, register, #render, #render_into, #rendering_parameters, #scope_vs_data, #subtype, #text, #to, #to_default, #to_s, #type, #with, #with!

Instance Method Details

#builderObject Also known as: rbml



28
29
30
# File 'lib/malt/formats/builder.rb', line 28

def builder(*)
  text
end

#html(*data, &content) ⇒ Object



40
41
42
43
# File 'lib/malt/formats/builder.rb', line 40

def html(*data, &content)
  #render_engine.render(:to=>:html, :text=>text, :file=>file, :data=>data, &yld)
  render_into(:html, *data, &content)
end

#to_builderObject Also known as: to_rbml



34
35
36
# File 'lib/malt/formats/builder.rb', line 34

def to_builder(*)
  self
end

#to_html(*data, &content) ⇒ Object



46
47
48
49
50
# File 'lib/malt/formats/builder.rb', line 46

def to_html(*data, &content)
  text = html(*data, &content)
  opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
  HTML.new(opts)
end