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
Add this line to your application's Gemfile:
gem 'cdnjs-rails'
```ruby
gem 'cdnjs-rails'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install cdnjs-rails
```
$ bundle
```
## 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

View File

@ -22,10 +22,10 @@ namespace :cdnjs do
}
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)
File.open(file_path, 'wb') do |file|
File.open file_path, 'wb' do |file|
file.write json
file.close
end

View File

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