M4Assets

Sprockets support for the M4 preprocessor.


M4Assets adds support for the GNU M4 general purpose macro processor to sprockets, allowing you to use textual macros in eg. your JavaScript, CoffeeScript, CSS or SCSS code.

Installation

The best way to install M4Assets is with RubyGems:

$ [sudo] gem install m4assets

Or add it to your Gemfile:

gem 'm4assets'

And then execute:

$ bundle install

If you’re installing from source, you can use Bundler to pick up all the gems, including those required for running the tests and creating coverage reports:

$ bundle install

Consult the online documentation for more information on Bundler

Dependencies

Getting started

M4Assets uses which to configure itself. You may, however, override the auto-detected location of the m4 binary:

M4Assets.configure do |config|
  config.path = "/path/to/m4"
end

Next you need to register M4Assets. If you are using Rails and you want to use m4 macros in your JavaScript code, you would create the following initializer:

Rails.application.assets.register_preprocessor 'application/javascript',
  M4Assets::Processor

Contributing

If you’d like to contribute to M4Assets, start by forking the repo on GitHub:

github.com/tobiassvn/m4assets

To get all of the dependencies, install the gem first. The best way to getyour changes merged back into core is as follows:

  • Clone down your fork.

  • Create a thoughtfully named topic branch to contain your change.

  • Hack away.

  • Add tests and make sure everything still passes by running rake.

  • If you are adding new functionality, document it in the README.

  • Do not change the version number, I will do that on my end.

  • If necessary, rebase your commits into logical chunks, without errors

  • Push the branch up to GitHub

  • Send a pull request to the tobiassvn/m4assets project.

License

Copyright (c) 2012 Tobias Svensson.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.