Code Monkey home page Code Monkey logo

js_assets's Introduction

js_assets

Gem provides a helper asset_path in javascript.

Installation

Add gem to your Gemfile

gem 'js_assets'

And run bundle install.

Usage

In your application.js

//= require app_assets

This directive adds the method asset_path in the global scope.

Get the path to the template app/assets/javascripts/rubrics/views/index.html in javascript:

var path = asset_path('rubrics/views/index.html')
// the function will return for development:
// /assets/rubrics/views/index.html
// and for production
// /assets/rubrics/views/index-5eb3bb250d5300736006c8944e436e3f.html

Settings

You can specify, for example in the initializer, which will be available in the helper asset_path, and which should be excluded.

To add a file to the list, use:

JsAssets::List.allow << '*.png'

To exclude:

JsAssets::List.exclude << '*.png'

Initially, the list is taken asset falling within the filter app/config/environments/production.rb

config.assets.precompile += ['*.html']

By default:

JsAssets::List.exclude = ["application.js"]
JsAssets::List.allow = ["*.html"]

Be careful! If the list of available JsAssets::List.allow get a file that is inserted directive require app_assets, recursion will occur as sprockets will calculate the md5-based content.

License

Copyright © 2013 Zaur Abasmirzoev <[email protected]>

JsAssets is distributed under an MIT-style license. See LICENSE for details.

js_assets's People

Contributors

izaurio avatar

Watchers

James Cloos avatar Markus Seeger 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.