Module: Vedeu::Templating::Helpers
Overview
Provide helpers to be used with your Vedeu templates.
Instance Method Summary collapse
- #background(value, &block) ⇒ Vedeu::Views::Stream (also: #bg)
- #colour(attributes = {}, &block) ⇒ Vedeu::Views::Stream
- #define_stream(attributes = {}, &block) ⇒ Object private
- #encode(data) ⇒ String private
- #foreground(value, &block) ⇒ Vedeu::Views::Stream (also: #fg)
- #style(value, &block) ⇒ Vedeu::Views::Stream
Methods included from View
Instance Method Details
#background(value, &block) ⇒ Vedeu::Views::Stream Also known as: bg
17 18 19 |
# File 'lib/vedeu/templating/helpers.rb', line 17 def background(value, &block) define_stream(background: value, &block) end |
#colour(attributes = {}, &block) ⇒ Vedeu::Views::Stream
30 31 32 |
# File 'lib/vedeu/templating/helpers.rb', line 30 def colour(attributes = {}, &block) define_stream(attributes, &block) end |
#define_stream(attributes = {}, &block) ⇒ Object (private)
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/vedeu/templating/helpers.rb', line 53 def define_stream(attributes = {}, &block) raise Vedeu::Error::RequiresBlock unless block_given? value = yield encode( Vedeu::Views::Stream.build( colour: Vedeu::Colours::Colour.new(attributes), style: Vedeu::Presentation::Style.new(attributes[:style]), value: value ) ) end |
#encode(data) ⇒ String (private)
69 70 71 |
# File 'lib/vedeu/templating/helpers.rb', line 69 def encode(data) Vedeu::Templating::Encoder.process(data) end |
#foreground(value, &block) ⇒ Vedeu::Views::Stream Also known as: fg
38 39 40 |
# File 'lib/vedeu/templating/helpers.rb', line 38 def foreground(value, &block) define_stream(foreground: value, &block) end |
#style(value, &block) ⇒ Vedeu::Views::Stream
46 47 48 |
# File 'lib/vedeu/templating/helpers.rb', line 46 def style(value, &block) define_stream(style: value, &block) end |