Class: Curlybars::Node::Root

Inherits:
Struct
  • Object
show all
Defined in:
lib/curlybars/node/root.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#positionObject

Returns the value of attribute position

Returns:

  • (Object)

    the current value of position



3
4
5
# File 'lib/curlybars/node/root.rb', line 3

def position
  @position
end

#templateObject

Returns the value of attribute template

Returns:

  • (Object)

    the current value of template



3
4
5
# File 'lib/curlybars/node/root.rb', line 3

def template
  @template
end

Instance Method Details

#compileObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/curlybars/node/root.rb', line 4

def compile
  # NOTE: the following is a heredoc string, representing the ruby code fragment
  # outputted by this node.
  <<-RUBY
    contexts = [presenter]
    variables = [{}]
    has_rendering_context = defined?(rendering_context)
    rendering = ::Curlybars::RenderingSupport.new(
      ::Curlybars.configuration.rendering_timeout,
      contexts,
      variables,
      #{position.file_name.inspect},
      global_helpers_providers,
      ::Curlybars.configuration.cache,
      start_time: has_rendering_context ? rendering_context[:start_time] : nil,
      depth: has_rendering_context ? rendering_context[:depth] : 0,
      partial_provider: partial_provider
    )
    buffer = ::Curlybars::SafeBuffer.new
    #{template.compile}
    buffer
  RUBY
end

#validate(branches, context: nil) ⇒ Object



28
29
30
# File 'lib/curlybars/node/root.rb', line 28

def validate(branches, context: nil)
  template.validate(branches, context: context)
end