module Wunderbar::Template::Text

Public Class Methods

ext() click to toggle source
# File lib/wunderbar/sinatra.rb, line 143
def self.ext; ['text.rb', :_text]; end
mime() click to toggle source
# File lib/wunderbar/sinatra.rb, line 144
def self.mime; 'text/plain'; end

Public Instance Methods

evaluate(scope, locals, &block) click to toggle source
# File lib/wunderbar/sinatra.rb, line 146
def evaluate(scope, locals, &block)
  builder = TextBuilder.new(scope)
  begin
    result = _evaluate(builder, scope, locals, &block)

    # if no output was produced, use the result
    builder._ result.to_s if builder.target!.empty? and result

    scope.response.status = 404 if builder.target!.empty?
  rescue Exception => exception
    scope.headers['Content-Type'] = self.class.default_mime_type
    scope.response.status = Wunderbar::ServerError.status
    builder._exception exception
  end
  builder.target!
end