class Rack::SinglePageApp::Template
Respond to generic server requests with a Mustache template, rendered with the provided context.
Mustache is an optional dependency, so needs to be required before this object is constructed.
@example
require 'mustache' context = { title: "App Title", body_class: "app-layout app-layout-fixed-width", root_element_id: "app-root", } run Rack::SinglePageApp::Template.new('assets/index.mustache', context)
Public Class Methods
new(path, context)
click to toggle source
@param path [String] Path to template @param context [Hash] Context object
Calls superclass method
Rack::SinglePageApp::Base::new
# File lib/rack/single_page_app.rb, line 57 def initialize(path, context) template = F.read(F.expand_path(path)) output = ::Mustache.render(template, context) super(output) end