Class: Vedeu::Templating::ViewTemplate Private
- Defined in:
- lib/vedeu/templating/view_template.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Extend Template to provide client application view specific parsing.
Instance Attribute Summary collapse
- #object ⇒ Class readonly protected private
- #options ⇒ Hash readonly protected private
Instance Method Summary collapse
-
#content ⇒ String
private
private
Return a string representing the template processed with ERB.
- #default ⇒ Hash<Symbol => Hash<Symbol => Symbol>,Symbol> private private
-
#interface ⇒ Vedeu::Interfaces::Interface
(also: #interface?)
private
private
Returns the named interface/view from the interfaces repository.
-
#lines ⇒ Array<String>
private
private
Convert the content into an array of strings without the line ending character.
-
#name ⇒ NilClass|Symbol|String
private
private
The name of the model, the target model or the name of the associated model.
- #parse ⇒ Vedeu::Views::Lines private
-
#stream_colour ⇒ Vedeu::Colours::Colour|Hash<Symbol => NilClass,String,Symbol>
private
private
Return the interface colours if a name option is set, otherwise use the default colours.
-
#stream_style ⇒ Symbol
private
private
Return the interface style(s) if a name option is set, otherwise use the default style.
-
#streams_for(line) ⇒ Array<String>
private
private
Returns the stream directives for the line.
Methods included from Helpers
#background, #colour, #define_stream, #encode, #foreground, #style
Methods included from View
Methods included from Common
#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?
Methods inherited from Template
#initialize, #load, parse, #path
Constructor Details
This class inherits a constructor from Vedeu::Templating::Template
Instance Attribute Details
#object ⇒ Class (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 |
# File 'lib/vedeu/templating/view_template.rb', line 48 def object @object end |
#options ⇒ Hash (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 |
# File 'lib/vedeu/templating/view_template.rb', line 52 def @options end |
Instance Method Details
#content ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return a string representing the template processed with ERB.
117 118 119 |
# File 'lib/vedeu/templating/view_template.rb', line 117 def content ERB.new(load, nil, '-').result(binding) end |
#default ⇒ Hash<Symbol => Hash<Symbol => Symbol>,Symbol> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 70 71 72 73 74 75 |
# File 'lib/vedeu/templating/view_template.rb', line 67 def default { colour: { background: :default, foreground: :default, }, style: :normal, } end |
#interface ⇒ Vedeu::Interfaces::Interface (private) Also known as: interface?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the named interface/view from the interfaces repository.
78 79 80 |
# File 'lib/vedeu/templating/view_template.rb', line 78 def interface Vedeu.interfaces.by_name(name) end |
#lines ⇒ Array<String> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert the content into an array of strings without the line ending character.
110 111 112 |
# File 'lib/vedeu/templating/view_template.rb', line 110 def lines content.lines.map(&:chomp) end |
#name ⇒ NilClass|Symbol|String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The name of the model, the target model or the name of the associated model.
84 85 86 |
# File 'lib/vedeu/templating/view_template.rb', line 84 def name [:name] end |
#parse ⇒ Vedeu::Views::Lines
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vedeu/templating/view_template.rb', line 18 def parse lines_collection = Vedeu::Views::Lines.new lines.each do |line| line_object = Vedeu::Views::Line.new streams_for(line).each do |stream| next unless present?(stream) line_object << if stream =~ /({{)|(}})/ Vedeu::Templating::Decoder.process(stream) else Vedeu::Views::Stream.new(colour: stream_colour, style: stream_style, value: stream) end end lines_collection << line_object end lines_collection end |
#stream_colour ⇒ Vedeu::Colours::Colour|Hash<Symbol => NilClass,String,Symbol> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the interface colours if a name option is set, otherwise use the default colours.
60 61 62 63 64 |
# File 'lib/vedeu/templating/view_template.rb', line 60 def stream_colour return interface.colour if name default[:colour] end |
#stream_style ⇒ Symbol (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the interface style(s) if a name option is set, otherwise use the default style.
100 101 102 103 104 |
# File 'lib/vedeu/templating/view_template.rb', line 100 def stream_style return interface.style if name default[:style] end |
#streams_for(line) ⇒ Array<String> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the stream directives for the line.
92 93 94 |
# File 'lib/vedeu/templating/view_template.rb', line 92 def streams_for(line) line.split(/({{\s*[^}]+\s*}})/) end |