Class: Rock::Doc::HTML::RenderingContext

Inherits:
Object
  • Object
show all
Defined in:
lib/rock/doc.rb

Overview

Base class for rendering contexts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, *default_template) ⇒ RenderingContext

Mapped object



130
131
132
133
# File 'lib/rock/doc.rb', line 130

def initialize(object, *default_template)
    @object = object
    @default_template = default_template
end

Instance Attribute Details

#default_templateObject (readonly)

Returns the value of attribute default_template



127
128
129
# File 'lib/rock/doc.rb', line 127

def default_template
  @default_template
end

#objectObject (readonly)

Returns the value of attribute object



126
127
128
# File 'lib/rock/doc.rb', line 126

def object
  @object
end

Instance Method Details

#help_tip(text) ⇒ Object

No help tips by default, it relies on having specialized mechanisms too much



148
# File 'lib/rock/doc.rb', line 148

def help_tip(text); "" end

No links by default



136
137
138
139
140
141
142
143
144
# File 'lib/rock/doc.rb', line 136

def link_to(arg)
    text =
        if arg.respond_to?(:name)
            arg.name
        else arg.to_s
        end

    Doc::HTML.escape_html(text)
end

#render(*template_path) ⇒ Object



159
160
161
162
# File 'lib/rock/doc.rb', line 159

def render(*template_path)
    template_path += [binding]
    HTML.render_template(*template_path)
end

#render_item(name, value = nil) ⇒ Object

Create an item for the rendering in tables



151
152
153
154
155
156
157
# File 'lib/rock/doc.rb', line 151

def render_item(name, value = nil)
    if value
        "<li><b>#{name}</b>: #{value}</li>"
    else
        "<li><b>#{name}</b></li>"
    end
end

#render_object(object, *template_path) ⇒ Object



164
165
166
# File 'lib/rock/doc.rb', line 164

def render_object(object, *template_path)
    HTML.render_object(object, *template_path)
end