Class: ComponentExample
- Inherits:
-
ExpressTemplates::Component
- Object
- ExpressTemplates::Component
- ComponentExample
- Defined in:
- app/components/component_example.rb
Instance Method Summary collapse
- #component_name ⇒ Object
- #example_partial_name ⇒ Object
- #example_partial_path ⇒ Object
- #example_title ⇒ Object
- #expected_id ⇒ Object
- #format(value) ⇒ Object
- #output_id ⇒ Object
- #partial_body ⇒ Object
- #usage_id ⇒ Object
Instance Method Details
#component_name ⇒ Object
97 98 99 |
# File 'app/components/component_example.rb', line 97 def component_name config[:id].to_s end |
#example_partial_name ⇒ Object
86 87 88 89 90 |
# File 'app/components/component_example.rb', line 86 def example_partial_name s = component_name.dup s << "_#{config[:example_name]}" if config[:example_name] s end |
#example_partial_path ⇒ Object
82 83 84 |
# File 'app/components/component_example.rb', line 82 def example_partial_path "express_ui/uicomponents/examples/#{example_partial_name}" end |
#example_title ⇒ Object
74 75 76 77 78 79 80 |
# File 'app/components/component_example.rb', line 74 def example_title if config[:example_name] "Example #{config[:example_name].to_s.titleize}" else "Example" end end |
#expected_id ⇒ Object
72 |
# File 'app/components/component_example.rb', line 72 def expected_id; "#{example_partial_name}_expected"; end |
#format(value) ⇒ Object
64 65 66 67 68 |
# File 'app/components/component_example.rb', line 64 def format(value) io = StringIO.new PP.pp value, io io.string.html_safe end |
#output_id ⇒ Object
71 |
# File 'app/components/component_example.rb', line 71 def output_id; "#{example_partial_name}_output"; end |
#partial_body ⇒ Object
92 93 94 95 |
# File 'app/components/component_example.rb', line 92 def partial_body location = File.dirname(__FILE__) File.read(File.join(location, '..', 'views', 'express_ui', 'uicomponents', 'examples', "_#{example_partial_name}.html.et")) end |
#usage_id ⇒ Object
70 |
# File 'app/components/component_example.rb', line 70 def usage_id; "#{example_partial_name}_usage"; end |