Class: WebConsole::Controller
- Inherits:
-
Object
- Object
- WebConsole::Controller
- Defined in:
- lib/webconsole/controller.rb
Constant Summary collapse
- CSS_EXTENSION =
".css"- CSS_PATH_COMPONENT =
"css/"- JS_EXTENSION =
".js"- JS_PATH_COMPONENT =
"js/"
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(delegate = nil, erb_template_path = nil) ⇒ Controller
constructor
A new instance of Controller.
- #shared_javascript_include_tag(resource) ⇒ Object
- #shared_stylesheet_link_tag(resource) ⇒ Object
Constructor Details
#initialize(delegate = nil, erb_template_path = nil) ⇒ Controller
Returns a new instance of Controller.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/webconsole/controller.rb', line 10 def initialize(delegate = nil, erb_template_path = nil) @delegate = delegate template_erb = ERB.new(File.new(erb_template_path).read, nil, '-') html = template_erb.result(binding) if @delegate @delegate.load_html(html) end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/webconsole/controller.rb', line 9 def name @name end |
Instance Method Details
#shared_javascript_include_tag(resource) ⇒ Object
29 30 31 32 |
# File 'lib/webconsole/controller.rb', line 29 def shared_javascript_include_tag(resource) uri = URI.join(shared_resources_url, JS_PATH_COMPONENT, resource + JS_EXTENSION) return "<script type=\"text/javascript\" src=\"#{uri.to_s}\"></script>" end |
#shared_stylesheet_link_tag(resource) ⇒ Object
23 24 25 26 |
# File 'lib/webconsole/controller.rb', line 23 def shared_stylesheet_link_tag(resource) uri = URI.join(shared_resources_url, CSS_PATH_COMPONENT, resource + CSS_EXTENSION) return "<link rel=\"stylesheet\" href=\"#{uri.to_s}\" />" end |