Skip to content

Commit

Permalink
Fix these for passing Engine's spec
Browse files Browse the repository at this point in the history
  • Loading branch information
makenowjust committed Jul 13, 2015
1 parent 4e4cbee commit 8a8683b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/crustache/engine.cr
@@ -1,7 +1,7 @@
module Crustache
class Engine
def initialize(@basedir : String, @cache = false)
self.initialize ViewLoader.new @basedir, @cache
def initialize(basedir : String, cache = false)
@fs = ViewLoader.new basedir, cache
end

def initialize(@fs : FileSystem); end
Expand All @@ -27,12 +27,12 @@ module Crustache
@fs.load!(filename).try{|tmpl| self.render tmpl, model, output}
end

def render(tmpl : Template, model)
def render(tmpl : Tree::Template, model)
Crustache.render tmpl, model, @fs
end

def render(tmpl : Template, model, output : IO)
Crustache.render tmpl, model, @fs, io
def render(tmpl : Tree::Template, model, output : IO)
Crustache.render tmpl, model, @fs, output
end
end
end
8 changes: 8 additions & 0 deletions src/crustache/filesystem.cr
Expand Up @@ -3,6 +3,14 @@ require "./tree.cr"
module Crustache
abstract class FileSystem
abstract def load(value : String) : Tree::Template?

def load!(value : String) : Tree::Template
if tmpl = self.load value
return tmpl
else
raise "#{value} is not found"
end
end
end

class HashFileSystem < FileSystem
Expand Down

0 comments on commit 8a8683b

Please sign in to comment.