Class: Volt::ViewParser
- Defined in:
- lib/volt/server/html_parser/view_parser.rb
Instance Attribute Summary collapse
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Instance Method Summary collapse
-
#data ⇒ Object
Returns a parsed version of the data (useful for backend rendering and testing).
-
#initialize(html, template_path) ⇒ ViewParser
constructor
A new instance of ViewParser.
Constructor Details
#initialize(html, template_path) ⇒ ViewParser
Returns a new instance of ViewParser.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/volt/server/html_parser/view_parser.rb', line 12 def initialize(html, template_path) @template_path = template_path handler = ViewHandler.new(template_path) SandlebarsParser.new(html, handler) # Close out the last scope handler.scope.last.close_scope @templates = handler.templates end |
Instance Attribute Details
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
10 11 12 |
# File 'lib/volt/server/html_parser/view_parser.rb', line 10 def templates @templates end |
Instance Method Details
#data ⇒ Object
Returns a parsed version of the data (useful for backend rendering and testing)
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/volt/server/html_parser/view_parser.rb', line 27 def data templates = @templates.deep_clone templates.each_pair do |name, value| if value['bindings'] value['bindings'].each_pair do |number, binding| value['bindings'][number] = binding.map { |code| eval(code) } end end end templates end |