lib/linner/template.rb in linner-0.1.0 vs lib/linner/template.rb in linner-0.1.1
- old
+ new
@@ -1,25 +1,31 @@
-require 'tilt'
-require 'sass'
-require 'coffee_script'
+require "tilt"
+require "sass"
+require "coffee_script"
+module Tilt
+ class JavascriptTemplate < PlainTemplate
+ self.default_mime_type = 'application/javascript'
+ end
+
+ class CSSTemplate < PlainTemplate
+ self.default_mime_type = 'text/css'
+ end
+
+ Tilt.register Tilt::CSSTemplate, "css"
+ Tilt.register Tilt::JavascriptTemplate, "js"
+end
+
module Linner
class Template
- def initialize(path)
- @path = path
- end
-
- def render
- if supported_template? @path
- Tilt.new(@path).render
- else
- File.read @path
+ class << self
+ def template_for_script?(path)
+ [Tilt::JavascriptTemplate, Tilt::CoffeeScriptTemplate].include? Tilt[path]
end
- end
- private
- def supported_template?(path)
- %w[.coffee .sass .scss].include? File.extname(path)
+ def template_for_style?(path)
+ [Tilt::CSSTemplate, Tilt::SassTemplate, Tilt::ScssTemplate].include? Tilt[path]
+ end
end
end
end