Class: OMF::Web::Widget::MustacheWidget

Inherits:
AbstractWidget
  • Object
show all
Defined in:
lib/omf-web/widget/mustache_widget.rb

Overview

Renders the content of a moustache file in the context of a data source

Instance Attribute Summary collapse

Attributes inherited from AbstractWidget

#name, #opts, #widget_id, #widget_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractWidget

#layout?, #mime_type, #tools_menu, #widget_info

Constructor Details

#initialize(opts) ⇒ MustacheWidget

Returns a new instance of MustacheWidget.



17
18
19
20
21
22
# File 'lib/omf-web/widget/mustache_widget.rb', line 17

def initialize(opts)
  super opts
  # if (content_descr = opts[:content])
    # opts[:content_proxy] = OMF::Web::ContentRepository.create_content_proxy_for(content_descr, opts)  
  # end  
end

Instance Attribute Details

#content_proxyObject

Returns the value of attribute content_proxy.



15
16
17
# File 'lib/omf-web/widget/mustache_widget.rb', line 15

def content_proxy
  @content_proxy
end

Class Method Details

.create_mustache_widget(type, wdescr) ⇒ Object



11
12
13
# File 'lib/omf-web/widget/mustache_widget.rb', line 11

def self.create_mustache_widget(type, wdescr)
  return self.new(wdescr)
end

Instance Method Details

#collect_data_sources(ds_set) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/omf-web/widget/mustache_widget.rb', line 33

def collect_data_sources(ds_set)
  if @opts[:data_sources]
    @opts[:data_sources].each do |ds|
      ds_set.add(ds[:stream])
    end
  end
  ds_set
end

#contentObject



28
29
30
31
# File 'lib/omf-web/widget/mustache_widget.rb', line 28

def content()
  OMF::Web::Theme.require 'mustache_renderer'
  OMF::Web::Theme::MustacheRenderer.new(self, @opts)
end

#titleObject



24
25
26
# File 'lib/omf-web/widget/mustache_widget.rb', line 24

def title 
  @opts[:title] || 'No Title'
end