Sha256: 636dd680f7d032e323c8f473619b7b9435f5e5c24806b9bbefc3aac1e844fc87

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 Bytes

Contents

require "mustache"

module RogerStyleGuide::Templates::Mustache
  # Mustach template wrapper which handles partial
  # resolving.
  class MustacheTemplate < ::Mustache
    def render(template, data, template_context = nil)
      @template_context = template_context
      super(template, data)
    end

    def partial(name)
      path = @template_context.component_template_paths(name.to_s + ".mst").find do |template_path|
        result = @template_context.renderer.send(:find_partial, template_path)
        break result if result
      end

      if path
        File.read(path)
      else
        fail "No such Mustache partial found: #{name}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roger_style_guide-0.1.0 lib/roger_style_guide/templates/mustache/mustache_template.rb