class Thymeleaf::TemplateEngine

Public Instance Methods

call(parsed_template, context_holder) click to toggle source
# File lib/thymeleaf/template_engine.rb, line 5
def call(parsed_template, context_holder)
  process_node(context_holder, parsed_template)
  parsed_template
end

Private Instance Methods

process_attribute(context_holder, node, attribute_key, attribute) click to toggle source
# File lib/thymeleaf/template_engine.rb, line 29
def process_attribute(context_holder, node, attribute_key, attribute)
  # TODO: Find all proccessors. Apply in precedence order!
  dialects = Thymeleaf.configuration.dialects
  key, processor = * dialects.find_attr_processor(attribute_key)
  
  process_element(context_holder, node, attribute, key, processor)
end
process_attributes(context_holder, node) click to toggle source
# File lib/thymeleaf/template_engine.rb, line 19
def process_attributes(context_holder, node)
  attr_context = context_holder
  if(node.respond_to?(:attributes))
    node.attributes.each do |attribute_key, attribute|
      attr_context = process_attribute(attr_context, node, attribute_key, attribute)
    end
  end
  attr_context
end
process_element(context_holder, node, attribute, key, processor) click to toggle source
# File lib/thymeleaf/template_engine.rb, line 48
def process_element(context_holder, node, attribute, key, processor)
  subcontext = processor.call(key: key, node: node, attribute: attribute, context: context_holder)

  if processor_has_subcontext?(processor)
    subcontext
  else
    context_holder
  end
end
process_node(context_holder, node) click to toggle source
# File lib/thymeleaf/template_engine.rb, line 11
def process_node(context_holder, node)
  attr_context = process_attributes(context_holder, node)
  children_context = process_tag(attr_context, node)
  
  # TODO: Processing all nodes. Maybe filtering by only-thymeleaf nodes can give better performance?
  node.children.each {|child| process_node(children_context, child)}
end
process_tag(context_holder, node) click to toggle source
# File lib/thymeleaf/template_engine.rb, line 37
def process_tag(context_holder, node)
  dialects = Thymeleaf.configuration.dialects
  key, processor = * dialects.find_tag_processor(node.name)

  process_element(context_holder, node, nil, key, processor)
end
processor_has_subcontext?(processor) click to toggle source
# File lib/thymeleaf/template_engine.rb, line 44
def processor_has_subcontext?(processor)
  processor.respond_to?(:has_subcontext?) && processor.has_subcontext?
end