Class: Handlebars

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/jazz/sprockets/templates/handlebars.rb

Constant Summary collapse

JS_ESCAPE_MAP =
{
    "\r\n"  => '\n',
    "\n"    => '\n',
    "\r"    => '\n',
    '"'     => '\\"',
    "'"     => "\\'"
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_mime_typeObject



13
14
15
# File 'lib/jazz/sprockets/templates/handlebars.rb', line 13

def self.default_mime_type
  'application/javascript'
end

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object



20
21
22
23
24
# File 'lib/jazz/sprockets/templates/handlebars.rb', line 20

def evaluate(scope, locals, &block)
  name = scope.logical_path.inspect.gsub('app/views/', '').gsub(/[\/]/, '_')
  content = indent(data).strip.gsub(/(\r\n|[\n\r"'])/) { JS_ESCAPE_MAP[$1] }		
"Jazz.View.add(#{name}, \"#{content}\")"
end

#prepareObject



17
18
# File 'lib/jazz/sprockets/templates/handlebars.rb', line 17

def prepare
end