{"id":20836293,"url":"https://github.com/igrigorik/closure-sprockets","last_synced_at":"2025-05-08T02:38:08.192Z","repository":{"id":62555804,"uuid":"2152516","full_name":"igrigorik/closure-sprockets","owner":"igrigorik","description":"Sprockets processor for Google's Closure tools","archived":false,"fork":false,"pushed_at":"2014-09-05T00:57:18.000Z","size":3616,"stargazers_count":54,"open_issues_count":4,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-18T17:08:22.353Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.igvita.com/2011/08/16/rails-3-asset-pipeline-google-closure/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igrigorik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-08-04T03:29:13.000Z","updated_at":"2020-10-15T13:26:58.000Z","dependencies_parsed_at":"2022-11-03T05:45:27.794Z","dependency_job_id":null,"html_url":"https://github.com/igrigorik/closure-sprockets","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrigorik%2Fclosure-sprockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrigorik%2Fclosure-sprockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrigorik%2Fclosure-sprockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrigorik%2Fclosure-sprockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igrigorik","download_url":"https://codeload.github.com/igrigorik/closure-sprockets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252988052,"owners_count":21836449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T00:29:24.176Z","updated_at":"2025-05-08T02:38:08.171Z","avatar_url":"https://github.com/igrigorik.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Closure Sprockets\n\nSprockets preprocessor for Google's [Closure tools](http://code.google.com/closure/) + Closure-templates (soy) compiler + Closure stylesheets (gss) compiler.\n\n## Integrating with Rails 3\n\nIf you want to use closure as your Javascript library in Rails 3, add this gem to your Gemfile:\n\n```ruby\ngem 'closure-sprockets'\n````\nThe gem ships with a Railtie which will automatically register a Closure preprocessor. From here, three more steps:\n\n- [Download the latest version](http://code.google.com/closure/library/docs/gettingstarted.html) of closure library from Google and put it in `vendor/assets` or another appropriate folder\n- Create `require_file.js` that will be your closure start point and include it with new directive `require_closure` at your `application.js`:  \n`//= require_closure require_file`\n- Write some closure code!\n\n\n### Javascripts\n\n```js\n// in your javascript `require_file.js` file or any depended file\ngoog.require('goog.dom');\n\nfunction sayHello() {\n  newHeader = goog.dom.createDom('h1', {}, 'Hello world!');\n  goog.dom.appendChild(document.body, newHeader);\n};\n\nwindow.onload = sayHello;\n```\n\nYou can also add a `name.soy` template in your assets folder and require it by standard `require` directive, and it will be automatically compiled to Javascript for you! Ex:\n\n```js\n/** hello.soy */\n\n{namespace examples.simple}\n\n/**\n * Says hello to the world.\n */\n{template .helloSoy}\n  Hello from Soy!\n{/template}\n```\n\n```js\n//= require examples/simple\n\nvar soy = goog.dom.createDom('h1', {'style': 'background-color:#EEE'}, examples.simple.helloSoy());\ngoog.dom.appendChild(document.body, soy);\n```\n\nThat's it! Point your browser at your page and you should have a hello world greeting from Google Closure, preprocessed by the Rails 3 Asset Pipeline and without any external Python dependencies or dynamic Javascript loading.\n\n\n### Stylesheets\n\nYou can use also [closure stylesheets](http://code.google.com/p/closure-stylesheets/) in .gss files\n\n```css\n/** style.gss **/\n\n@def BG_COLOR              rgb(235, 239, 249);\n\n@def DIALOG_BORDER_COLOR   rgb(107, 144, 218);\n@def DIALOG_BG_COLOR       BG_COLOR;\n\nbody {\n  background-color: BG_COLOR;\n}\n\n.dialog {\n  background-color: DIALOG_BG_COLOR;\n  border: 1px solid DIALOG_BORDER_COLOR;\n}\n```\n\nGSS files will be compiled automatically to CSS:\n\n```css\nbody {\n  background-color: #ebeff9;\n}\n.dialog {\n  background-color: #ebeff9;\n  border: 1px solid #6b90da;\n}\n```\n\n\n\n## Using Closure Compressor for Minification\n\nClosure also provides its own Javascript compressor. If you wish to use it, pull in the [closure-compiler](https://github.com/documentcloud/closure-compiler) gem:\n\n```ruby\n# in your Gemfile\ngem 'closure-compiler'\n````\n\n```ruby\n# in your environment configuration\nconfig.assets.js_compressor = Closure::Compiler.new\n```\n\nIf you are not using the closure compiler, then you may want to disable the dynamic deps.js loading. To do so, add the following snippet in `application.html.erb` above the javascript_include tag:\n\n```html\n\u003cscript type=\"text/javascript\"\u003e\n  var CLOSURE_NO_DEPS = true;\n\u003c/script\u003e\n```\n\n### License\n\n(MIT License) - Copyright \u0026copy; 2011 Ilya Grigorik\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figrigorik%2Fclosure-sprockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figrigorik%2Fclosure-sprockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figrigorik%2Fclosure-sprockets/lists"}