Module: Vedeu::Templating::Helpers

Includes:
View
Included in:
ViewTemplate
Defined in:
lib/vedeu/templating/helpers.rb

Overview

Provide helpers to be used with your Vedeu templates.

Instance Method Summary collapse

Instance Method Details

#background(value, &block) ⇒ Vedeu::Views::Stream Also known as: bg

Parameters:

  • value (String)

    The HTML/CSS colour.

  • block (Proc)

Returns:

Raises:



15
16
17
# File 'lib/vedeu/templating/helpers.rb', line 15

def background(value, &block)
  define_stream(background: value, &block)
end

#colour(attributes = {}, &block) ⇒ Vedeu::Views::Stream

Parameters:

  • attributes (Hash) (defaults to: {})
  • block (Proc)

Options Hash (attributes):

  • foreground (String)

    The HTML/CSS foreground colour.

  • background (String)

    The HTML/CSS background colour.

Returns:

Raises:



28
29
30
# File 'lib/vedeu/templating/helpers.rb', line 28

def colour(attributes = {}, &block)
  define_stream(attributes, &block)
end

#define_stream(attributes = {}, &block) ⇒ Object (private)

See Also:



51
52
53
54
55
56
57
58
59
# File 'lib/vedeu/templating/helpers.rb', line 51

def define_stream(attributes = {}, &block)
  fail Vedeu::Error::RequiresBlock unless block_given?

  encode(
    Vedeu::Views::Stream.build(
      colour: Vedeu::Colours::Colour.new(attributes),
      style:  Vedeu::Presentation::Style.new(attributes[:style]),
      value:  block.call))
end

#encode(data) ⇒ String (private)

Parameters:

  • data (String)

Returns:

  • (String)


63
64
65
# File 'lib/vedeu/templating/helpers.rb', line 63

def encode(data)
  Vedeu::Templating::Encoder.process(data)
end

#foreground(value, &block) ⇒ Vedeu::Views::Stream Also known as: fg

Parameters:

  • value (String)

    The HTML/CSS colour.

  • block (Proc)

Returns:

Raises:



36
37
38
# File 'lib/vedeu/templating/helpers.rb', line 36

def foreground(value, &block)
  define_stream(foreground: value, &block)
end

#style(value, &block) ⇒ Vedeu::Views::Stream

Parameters:

  • value (Symbol)
  • block (Proc)

Returns:



44
45
46
# File 'lib/vedeu/templating/helpers.rb', line 44

def style(value, &block)
  define_stream(style: value, &block)
end

#time_nowString Originally defined in module View

Returns the current local time.

Examples:

time_now # => Mon 29 Jun 19:26

Returns:

  • (String)