alchaplinsky/polymer-rails
{ "createdAt": "2014-06-30T00:57:57Z", "defaultBranch": "master", "description": "Polymer and web components for Ruby on Rails", "fullName": "alchaplinsky/polymer-rails", "homepage": null, "language": "HTML", "name": "polymer-rails", "pushedAt": "2022-11-08T21:36:28Z", "stargazersCount": 286, "topics": [], "updatedAt": "2024-07-14T07:02:16Z", "url": "https://github.com/alchaplinsky/polymer-rails"}Polymer-Rails
Section titled “Polymer-Rails”Want to get started with web components? Want to bring them into your Rails app? Easily build your own and use web components that are built by community in your Ruby on Rails Application. Polymer-rails helps you to do this:
-
Adds polymer library to assets of your rails project.
-
Allows you to easily import web component with
<%= html_import_tag "my-component" %>helper. -
Allows you to import and package web components into assets pipeline, exactly as you would Javascript or CSS
Prefer using SASS or CoffeeSript?
Section titled “Prefer using SASS or CoffeeSript?”Polymer-rails works well with compiling assets, such as CoffeeScript and Sass.
You can easily use external stylesheet or script tag references in your web component <link rel="stylesheet" href="application.css"> for stylesheets and <script unsrc="application.js"> for javascripts.
This assets will be automatically compiled and required into component html file.
- Note that if you’re using sass or coffee precompilation, assets are required to use ‘.css.sass’ and ‘.js.coffee’ extensions.*
Versions
Section titled “Versions”Polymer 2.0 is out!
- Use
0.2.xversions ofpolymer-railsto work with Polymer versions0.5.x - Use
1.0.xversions ofpolymer-railsto work with Polymer versions1.0.x - Use
2.0.xversions ofpolymer-railsto work with Polymer versions2.0.x
1.0 release is not compatible with the 0.5 APIs. For guidance on migrating an existing 0.5 elements to the 1.0 APIs, see the Migration guide.
Installation
Section titled “Installation”Add this line to your application’s Gemfile:
gem 'polymer-rails'And then execute:
$ bundleOr install it yourself as:
$ gem install polymer-railsInstallation
Section titled “Installation”$ rails g polymer:install- This generator adds
//= require webcomponentsjs/webcomponents-loaderintoapplication.jsmanifest file - Creates
app/assets/componentsandapplication.htmlmanifest file where you can include all your components. - Creates
vendor/assets/componentsdirectory for third-party web components.
After running rails g polymer:install, add <%= html_import_tag 'application'%> line into your layout,
to import web components manifest to your app.
Creating a component
Section titled “Creating a component”$ rails g polymer:component <component-name>This generates new <component-name> component directory and .html, .css, .js files of the same name under app/assets/components folder.
Add your component to .html manifest file after requiring polymer:
////= require polymer/polymer//= require component-name/component-nameAnd you can use your component in Rails application!
Polymer core/paper elements
Section titled “Polymer core/paper elements”Polymer team is working on set of core element which you can learn more about here http://www.polymer-project.org/docs/elements/core-elements.html. If you want to use them in your Rails application, checkout polymer-core-rails gem.
You may also be interested in Polymer paper elements, they are also available as polymer-paper-rails gem.
Example
Section titled “Example”See example Rails application here http://polymer-rails-example.herokuapp.com/
Source code can be found here https://github.com/alchapone/polymer-rails-example
Learn more
Section titled “Learn more”You can check out http://customelements.io/ or http://component.kitchen/ to see what components are already built by community.
Contributing
Section titled “Contributing”- Fork it ( http://github.com/alchapone/polymer-rails/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request