Sha256: ec90d2e15e1435310c68c2d9e5d6a3287f1b44ad531e6abc9f6ee2f630e0f5bc
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'tilt' module HoganAssets class Tilt < Tilt::Template self.default_mime_type = 'application/javascript' def initialize_engine require_template_library 'haml' rescue LoadError # haml not available end def evaluate(scope, locals, &block) text = if scope.pathname.extname == '.hamstache' raise "Unable to complile #{scope.pathname} because haml is not available. Did you add the haml gem?" unless HoganAssets::Config.haml_available? Haml::Engine.new(data, @options).render else data end compiled_template = Hogan.compile(text) template_name = scope.logical_path.inspect # Only emit the source template if we are using lambdas text = '' unless HoganAssets::Config.lambda_support? <<-TEMPLATE this.HoganTemplates || (this.HoganTemplates = {}); this.HoganTemplates[#{template_name}] = new Hogan.Template(#{compiled_template}, #{text.inspect}, Hogan, {}); TEMPLATE end protected def prepare; end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hogan_assets-1.3.1 | lib/hogan_assets/tilt.rb |