Sha256: 0562df5ee195d096a979e9ffe0f5a8ebc1c4c1005b0296d78f68aa79d2a36c4b
Contents?: true
Size: 912 Bytes
Versions: 1
Compression:
Stored size: 912 Bytes
Contents
require 'pathname' require 'nm/template' module Nm class Source EXT = ".nm" attr_reader :root def initialize(root) @root = Pathname.new(root.to_s) end def data(file_path) File.send(File.respond_to?(:binread) ? :binread : :read, file_path) end def render(file_name, locals = nil) Template.new(self, source_file_path(file_name), locals || {}).__data__ end def partial(file_name, locals = nil) Template.new(self, partial_file_path(file_name), locals || {}).__data__ end private def source_file_path(file_name) self.root.join("#{file_name}#{EXT}").to_s end def partial_file_path(file_name) basename = File.basename(file_name.to_s) source_file_path(file_name.to_s.sub(/#{basename}\Z/, "_#{basename}")) end end class DefaultSource < Source def initialize super('/') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nm-0.2.0 | lib/nm/source.rb |