Created
July 24, 2011 19:31
-
-
Save kareemk/1102990 to your computer and use it in GitHub Desktop.
Stitch-rb Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StitchApplication < Stitch::Server | |
def initialize | |
settings = YAML.load_file("config/stitch.yml") | |
super(:paths => settings["paths"], :dependencies => settings["dependencies"]) | |
end | |
def call(env) | |
if Rails.env == "production" | |
[200, {"Content-Type" => "text/javascript"}, [Uglifier.compile(@package.compile)]] | |
else | |
super | |
end | |
end | |
end | |
class TmplCompiler < Stitch::Compiler | |
# List of supported extensions | |
extensions :tmpl | |
# A compile method which takes a file path, | |
# and returns a compiled string | |
def compile(path) | |
content = File.read(path) | |
%{ | |
var template = jQuery.template(#{content.to_json}); | |
module.exports = (function(data){ return jQuery.tmpl(template, data); }); | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment