Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View application.js
1 2 3 4 5 6
goog.require('goog.dom');
 
function sayHi() {
var newHeader = goog.dom.createDom('h1', {'style': 'background-color:#EEE'}, 'Hello world!');
goog.dom.appendChild(document.body, newHeader);
}
View application.js
1 2 3 4 5 6 7 8 9
# initializer
 
require 'klosure-tilt'
 
path = File.expand_path("../../../app/assets/javascripts/closure-library/closure", __FILE__)
p [:closure_lib_path, path]
 
Rails.application.assets.append_path path
Rails.application.assets.register_preprocessor 'application/javascript', ClosureDependenciesProcessor
View application.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
require 'tilt'
 
class ClosureDependenciesProcessor < Tilt::Template
def prepare; end
 
def evaluate(context, locals, &block)
p [:CALCDEPS_START]
p [:data, data]
 
context.require_asset 'goog/base'
 
data.lines.each do |line|
if line =~ /goog\.require\s*\(\s*[\'\"]([^\)]+)[\'\"]\s*\)/
goog, mod, sub = $1.split(".")
sub ||= mod
mod, sub = mod.downcase, sub.downcase
dep = [goog, mod, sub].join("/")
 
p [:require_asset, dep]
context.require_asset(dep)
end
end
 
data
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.