Code Monkey home page Code Monkey logo

middleman-sprockets's Introduction

The master branch is the 4.x version of Middleman-Sprockets.

Middleman-Sprockets

middleman-sprockets is an extension for the Middleman static site generator that allows support for Sprockets in your assets.

Installation

If you're just getting started, install the middleman gem and generate a new project:

gem install middleman
middleman init MY_PROJECT

Then add gem "middleman-sprockets" to your Gemfile and run bundle install

To activate the extension, in your config.rb add:

activate :sprockets

Usage

Configuration

There are currently two options for configuration, imported_asset_path and expose_middleman_helpers.

imported_asset_path [default: 'assets']

This is the path imported/linked assets will be added to the sitemap. For example, in the bower fixture app, the /javascripts/core.js file has //= link "lightbox2/img/close.png". This linked asset will be added to the sitemap at /assets/lightbox2/img/close.png.

To configure, in config.rb:

activate :sprockets do |c|
  c.imported_asset_path = "YOUR_PATH"
end

You can also pass an object (proc/lambda/class) that responds to #call to imported_asset_path to conditionally determine where assets go.

activate :sprockets do |c|
  c.imported_asset_path = ->(sprockets_asset) do
    if sprockets_asset.logical_path =~ /\.js$/
      # all files ending with .js get put in /vendor-js
      File.join('vendor-js', sprockets_asset.logical_path)
    else
      # other assets head to /imported
      File.join('imported', sprockets_asset.logical_path)
    end
  end
end

View the imported_asset_processor test for an example using a class.

expose_middleman_helpers [default: false]

Sometimes you might need sprockets to have access helpers (for example using different keys depending on deployment environment). Getting this to happen is bound to be full of edge cases, so for now it's behind a configuration option.

If you need Middleman helpers in your Sprockets, in config.rb:

activate :sprockets do |c|
  c.expose_middleman_helpers = true
end

Build & Dependency Status

Gem Version Build Status Dependency Status Code Quality

Community

The official community forum is available at: http://forum.middlemanapp.com

Bug Reports

Github Issues are used for managing bug reports and feature requests. If you run into issues, please search the issues and submit new problems: https://github.com/middleman/middleman-sprockets/issues

The best way to get quick responses to your issues and swift fixes to your bugs is to submit detailed bug reports, include test cases and respond to developer questions in a timely manner. Even better, if you know Ruby, you can submit Pull Requests containing Cucumber Features which describe how your feature should work or exploit the bug you are submitting.

How to Run Cucumber Tests

  1. Checkout Repository: git clone https://github.com/middleman/middleman-sprockets.git
  2. Install Bundler: gem install bundler
  3. Run bundle install inside the project root to install the gem dependencies.
  4. Run test cases: bundle exec rake test

Donate

Click here to lend your support to Middleman

License

Copyright (c) 2012-2016 Thomas Reynolds. MIT Licensed, see LICENSE for details.

middleman-sprockets's People

Contributors

tdreyno avatar stevenosloan avatar bhollis avatar alem0lars avatar karlfreeman avatar mc-jordan-andree avatar manuelmeurer avatar maxmeyer avatar lawso017 avatar arcovion avatar tricknotes avatar ssaunier avatar alex88 avatar dominikguzei avatar ball-hayden avatar joefiorini avatar joshingly avatar onemanstartup avatar rmm5t avatar pwnall avatar kt3k avatar igoralekseev avatar kematzy avatar

Watchers

James Cloos avatar Boris Paillard avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.