Skip to content
Create a gist now

Instantly share code, notes, and snippets.

goog.require('goog.dom');
function sayHi() {
var newHeader = goog.dom.createDom('h1', {'style': 'background-color:#EEE'}, 'Hello world!');
goog.dom.appendChild(document.body, newHeader);
}
# 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
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.