lib/volt/server/template_handlers/view_processor.rb in volt-0.9.5 vs lib/volt/server/template_handlers/view_processor.rb in volt-0.9.6.pre1
- old
+ new
@@ -21,11 +21,11 @@
'volt_app'
end
end
def cache_key
- @cache_key ||= "#{self.class.name}:0.1".freeze
+ @cache_key ||= "#{self.class.name}:0.2".freeze
end
# def evaluate(context, locals, &block)
# binding.pry
# @data = compile(@data)
@@ -63,12 +63,10 @@
def compile(view_path, html, context)
exts = ComponentTemplates::Preprocessors.extensions
template_path = view_path.split('/')[-4..-1].join('/').gsub('/views/', '/').gsub(/[.](#{exts.join('|')})$/, '')
- exts = ComponentTemplates::Preprocessors.extensions
-
format = File.extname(view_path).downcase.delete('.').to_sym
code = ''
# Process template if we have a handler for this file type
if handler = ComponentTemplates.handler_for_extension(format)
@@ -80,10 +78,12 @@
return [Opal.compile(code), parser.links]
end
def self.setup(sprockets=$volt_app.sprockets)
- sprockets.register_mime_type 'application/vtemplate', extensions: ['.html', '.email']
+ exts = ComponentTemplates::Preprocessors.extensions.map{ |ext| ".#{ext}" }
+
+ sprockets.register_mime_type 'application/vtemplate', extensions: exts
sprockets.register_transformer 'application/vtemplate', 'application/javascript', Volt::ViewProcessor.new(true)
end
end
end