lib/linner/template.rb in linner-0.10.0 vs lib/linner/template.rb in linner-0.11.0

- old
+ new

@@ -1,20 +1,31 @@ require "tilt" require "sass" require "compass/core" require "handlebars.rb" require "coffee_script" +require "babel/transpiler" module Tilt class YAMLTemplate < PlainTemplate self.default_mime_type = "text/x-yaml" end class JavascriptTemplate < PlainTemplate self.default_mime_type = "application/javascript" end + class BabelTemplate < PlainTemplate + self.default_mime_type = "application/javascript" + + def prepare; end + + def evaluate(scope, locals, &block) + @output ||= Babel::Transpiler.transform(data, compact: false)["code"] + end + end + class CSSTemplate < PlainTemplate self.default_mime_type = "text/css" end class CompassSassTemplate < SassTemplate @@ -53,9 +64,10 @@ register PlainTemplate, "txt" register CSSTemplate, "css" register JavascriptTemplate, "js" register YAMLTemplate, "yml", "yaml" + register BabelTemplate, "es6", "es", "jsx" register HandlebarsTemplate, "hbs", "handlebars" register CompassSassTemplate, "sass" prefer CompassSassTemplate