js inline

This commit is contained in:
tdreyno 2009-09-21 10:09:41 -07:00
parent 53c31245a7
commit 98ba9d7901
2 changed files with 15 additions and 3 deletions

View file

@ -2,8 +2,6 @@
# Require app
require 'templater'
require "yui/compressor"
require "sprockets"
MIDDLEMAN_BUILDER = true
require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')

View file

@ -6,6 +6,8 @@ require 'sinatra/base'
require 'sprockets'
require File.join(File.dirname(__FILE__), 'middleman', 'sprockets_ext')
require "yui/compressor"
# Include content_for support
require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-content-for', 'lib', 'sinatra', 'content_for')
@ -68,6 +70,19 @@ class Middleman < Sinatra::Base
Compass.configure_sass_plugin!
end
configure :build do
module Minified
module Javascript
include ::Haml::Filters::Base
def render_with_options(text, options)
compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
data = compressor.compress(text.rstrip.gsub("\n", "\n "))
%Q{<script type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}>#{data.chomp}</script>}
end
end
end
end
# CSS files
get %r{/(.*).css} do |path|
content_type 'text/css', :charset => 'utf-8'
@ -108,7 +123,6 @@ class Middleman < Sinatra::Base
result || pass
end
get %r{/(.*\.xml)} do |path|
content_type 'text/xml', :charset => 'utf-8'
haml(path.to_sym, :layout => false)