Sha256: d819ef768ec807895e3f182ea806f0b65b0c006dec966ee1a46b8ecfd143dea0
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require 'undies' module Assert::View # this module is mixed in to the Assert::View::Base class # it use Undies to define and render view templates module Renderer def self.included(receiver) receiver.send(:extend, ClassMethods) end # define rendering template class to use for rendering # need to overwrite the '_' and '__' meths to add trailing newlines # b/c streaming output doesn't add any whitespace class Template < ::Undies::Template def _(data="", nl=true); super(data.to_s + (nl ? "\n" : "")); end def __(data="", nl=true); super(data.to_s + (nl ? "\n" : "")); end end # this method is required by assert and is called by the test runner # use Undies to render the template # using the view's template file # streaming to the view's output io # passing in the view itself and any runner_callback as locals def render(*args, &runner_callback) Template.new(File.expand_path(self.template_file), self.output_io, { :view => self, :runner => runner_callback }) end module ClassMethods # make any helper methods available to the template def helper(helper_klass) Template.send(:include, helper_klass) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
assert-view-0.2.0 | lib/assert/view/renderer.rb |