Sha256: d6b935c8cb4e902d72f04de1ad74cf84b60cb92a8d87034a5cde867fa038a3ae
Contents?: true
Size: 1.56 KB
Versions: 3
Compression:
Stored size: 1.56 KB
Contents
# Stockor templates compiler # # This is a hacked together version of Sam Stephenson's Eco # project for embedded coffeescript templates. # # Our version has the various helper functions pre-loaded # so the templates themselves are smaller in size. # and also includes a "h" helper namespace require 'pathname' require 'tilt' module Skr module Workspace module EJSSource class << self def path @path ||= Pathname.new(__FILE__).dirname.join('eco.js') end def contents @contents ||= path.read end def combined_contents [CoffeeScript::Source.contents, contents].join(";\n") end def context @context ||= ExecJS.compile(combined_contents) end def compile(template) template = template.read if template.respond_to?(:read) context.call("eco.precompile", template, 'Skr.TemplateWrapper','Skr.View.Helpers') end end end class SkrTemplates < Tilt::Template self.default_mime_type = 'application/javascript' def evaluate(scope, locals, &block) "Skr.Templates['#{scope.logical_path}']=" + EJSSource.compile(data) end def prepare; # NOOP end def self.register(app) app.assets.register_engine(".skr", self ) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lanes-0.0.3 | lib/lanes/api/skr_templates.rb |
lanes-0.0.2 | lib/lanes/api/skr_templates.rb |
lanes-0.0.1 | lib/lanes/api/skr_templates.rb |