Giter VIP home page Giter VIP logo

emcee's Introduction

Emcee

Emcee is an extension to the Rails Asset Pipeline. It allows you to import and package web components exactly as you would Javascript or CSS.

Table of contents

Installation

Add Emcee to your Gemfile:

gem 'emcee'

and then execute:

$ bundle install

Finally, run:

$ rails generate emcee:install

This will insert <%= html_import_tag "application" %> into your application layout. Also, it will create 'components' directories under '/assets' and '/vendor/assets'.

Usage

Once installed, you will have a manifest file located at /assets/components/application.html. Use sprockets directives to include web components located in one of the assets directories.

When referencing web components, you must point to an html file, not a directory. For example, if you have a sub-directory like this:

vendor
|- assets
  |- components
    |- ui-tabs
       |- ui-tabs.html

You must reference this in the manifest file as:

*= require ui-tabs/ui-tabs

Compilation

Emcee works great with compiling assets, such as CoffeeScript and Sass. Any external stylesheet or script tag references that have an extension that Sprockets recognizes will automatically be compiled.

For example, <link rel="stylesheet" href="test.css.scss"> and <script src="test.js.coffee"> will be respectively compiled to CSS and Javascript.

Bower

When installed, Emcee configures Bower to install components to vendor/assets/components. Anything installed with bower can be referenced directly in your application.js, application.css, or application.html manifest files.

Concatenation

In a development environment, all web components referenced in the manifest will be included in the application as seperate html imports. Importing web components a.html, b.html, and c.html will result in:

<link rel="import" href="a.html">
<link rel="import" href="b.html">
<link rel="import" href="c.html">

In production, they will be concatenated into one import, and will have comments and blank lines removed.

<link rel="import" href="application-908e25f4bf641868d8683022a5b62f54.html">

Notice the fingerprint hash appended to the file name. This depends on the contents of the included web components, and allows proper caching and cache-busting.

Testing

To run the tests, simply run rake test.

Contributing

  1. Fork it
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

Special Thanks

Special thanks to the Polymer Project, which Emcee was designed to work with. They've designed an amazing piece of technology that will change how web apps are made.

emcee's People

Contributors

ahuth avatar datapimp avatar killinit avatar rastyagaev avatar pwnall avatar zamith avatar

Watchers

James Cloos 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.