1
0
Fork 0

Readme fixes

This commit is contained in:
Gregory Eremin 2013-07-17 20:56:30 +07:00
parent 588fdd0f64
commit 722c155a42
3 changed files with 39 additions and 17 deletions

View File

@ -1,24 +1,46 @@
# Cdnjs::Rails # [cdnjs](http://cdnjs.com) helpers for Rails apps
TODO: Write a gem description This gem adds view helpers to Ruby on Rails applications that embed javascripts
and stylesheets directly from [cdnjs](http://cdnjs.com)
## Installation ## Installation
Add this line to your application's Gemfile: Add this line to your application's Gemfile:
```ruby
gem 'cdnjs-rails' gem 'cdnjs-rails'
```
And then execute: And then execute:
```
$ bundle $ bundle
```
Or install it yourself as:
$ gem install cdnjs-rails
## Usage ## Usage
TODO: Write usage instructions here From view files
```
<html>
<head>
<title>Hello World!</title>
<%= stylesheet_cdnjs_tag 'normalize' %>
</head>
<body>
<%= yield %>
<%= javascript_cdnjs_tag 'jquery', version: '2.0.3', protocol: 'https' %>
</body>
</html>
```
From anywhere in the app
```ruby
CdnjsRails.package_url('chosen', v: '0.9.10', proto: 'http')
```
## Options
`version` (aliases: `ver`, `v`): package version, latest by default
`protocol` (alias: `proto`): url protocol, relative by default
## Contributing ## Contributing

View File

@ -22,10 +22,10 @@ namespace :cdnjs do
} }
end.inject(:merge) end.inject(:merge)
# Format JSON for better diffs and smaller patches # Pretty format JSON for better diffs and smaller patches
json = MultiJson.dump(data, :pretty => true) json = MultiJson.dump(data, :pretty => true)
File.open(file_path, 'wb') do |file| File.open file_path, 'wb' do |file|
file.write json file.write json
file.close file.close
end end

View File

@ -1,11 +1,11 @@
module CdnjsRails module CdnjsRails
module ViewHelpers module ViewHelpers
def javascript_cdnjs_tag name, version = nil def javascript_cdnjs_tag name, options = {}
javascript_include_tag CdnjsRails.package_url(name, version) javascript_include_tag CdnjsRails.package_url(name, options)
end end
def stylesheet_cdnjs_tag name, version = nil def stylesheet_cdnjs_tag name, options = {}
stylesheet_include_tag CdnjsRails.package_url(name, version) stylesheet_include_tag CdnjsRails.package_url(name, options)
end end
end end
end end