Sha256: 7b464c893299a34d17ef91e22f81ce0041dd06182ecba132499e03c7baa3553b
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'tilt' module Lotus module View # A logic-less template. # # @since 0.1.0 class Template def initialize(template, encoding = Encoding::UTF_8) @_template = Tilt.new(template, nil, default_encoding: encoding) end # Returns the format that the template handles. # # @return [Symbol] 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(/\.([^.]+)/).captures.first.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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lotus-view-0.5.0 | lib/lotus/view/template.rb |