forked from kaievns/frontcompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
JavaScript/CSS/HTML sources compiler
License
ValMilkevich/frontcompiler
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Welcome! ======== FrontCompiler is a simple collection of compactors for the JavaScript, CSS and HTML source code. It removes trailing whitespaces, comments and transformates the local variables to make the sourcecode shorter. The library can be used as a plugin for rails. See description below. Usage ===== It's pretty simple @c = FrontCompiler.new @compact_js = @c.compact_js(File.open('src/something.js', 'r')); @compact_css = @c.compact_css(File.open('src/something.css', 'r')); @compact_html = @c.compact_html(File.open('src/something.css', 'r')); or shorter @compact_js = @c.compact_file('src/something.js'); @compact_css = @c.compact_file('src/something.css'); @compact_html = @c.compact_file('src/something.css'); or you can compact several files at once like that @library_code = @c.compact_files(%w{ src/lib.js src/lib/something.js src/lib/another.js }) Same for the other file-types CSS Inlining ============ With the tool you can convert your css source in some javascript definition so you could put the styles in the same file as your javascript and have -1 (or several) hits to your sever. File('public/javascripts/all_in_one.js', 'w') do |file| file.write @c.compact_files(%w{ public/javascripts/prototype.js public/javascripts/effects.js public/javascripts/application.js }) file.write @c.inline( File.open('public/stylesheets/application.css').read ) end Now you have a single javascript file which contains both, javascript and the application stylesheets in one. NOTE: if the user have JavaScript switched off, then he won't see the styles. Rails Usage =========== The project can be used as a usual rails plugin. Just clone the project into your vendor/plugins/front_compiler directory and you will have the following methods aviable both in your controllers and templates * compact_files(list) - compacts the files fromt the given list and puts them in a single string. You can specify a list of file-names here. * compact_file(file) - compacts the given file (can be a file-name) * compact_js(source) - returns compacted version of the given source * compact_css(source) * compact_html(source) * inline_css(source) - converts the css-source in javascript * inline_css_file(file) - converts the given css-file in a javascript source (can be a file-name) Enjoy! -- The code released under terms of the MIT License Copyright (C) 2008 Nikolay V. Nemshilov aka St.
About
JavaScript/CSS/HTML sources compiler
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- Ruby 100.0%