Sha256: e715268335514323a51f9b62ea8820cc532e8d9a8348a69264255ce097479b1d
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
require 'tilt' module Lotus module View # A logic-less template. # # @since 0.1.0 class Template def initialize(template) @_template = Tilt.new(template) end # Returns the format that the template handles. # # @return [String] the format name # # @since 0.1.0 # # @example # require 'lotus/view' # # template = Lotus::View::Template.new('index.html.erb') # template.format # => 'html' def format @_template.basename.match(/(\.[^.]+)/).to_s. gsub('.', ''). # TODO shame on me, this should be part of the regex above to_sym end # Render the template within the context of the given scope. # # @param scope [Lotus::View::Scope] the rendering scope # # @return [String] the output of the rendering process # # @api private # @since 0.1.0 # # @see Lotus::View::Scope def render(scope, &blk) @_template.render(scope, {}, &blk) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lotus-view-0.2.0 | lib/lotus/view/template.rb |
lotus-view-0.1.0 | lib/lotus/view/template.rb |