knockout-assets 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## Version 0.0.1
2
+
3
+ First commit.
data/README.md CHANGED
@@ -1,3 +1,41 @@
1
1
  # Knockout Assets
2
2
 
3
- A gem to generate paths for knockout templates using the asset pipeline.
3
+ [Knockout Assets](https://github.com/hlascelles/knockout-assets) is a Rails gem that generates full asset URL paths for assets in the asset pipeline.
4
+ It also supplies simple bindings for using assets in [Knockout](http://knockoutjs.com/) templates. This makes it very useful for applications that use
5
+ [Knockout](http://knockoutjs.com/) and CDNs.
6
+
7
+ ## Usage
8
+
9
+ Install:
10
+
11
+ gem 'knockout-assets'
12
+
13
+ Add the loader in yout application.html.erb:
14
+
15
+ <%= knockout_assets %>
16
+
17
+ Then use in a template:
18
+
19
+ <img data-bind="img: 'person.gif'">
20
+
21
+ ## Why?
22
+
23
+ Asset URLs change depending on how they are served up. In production, assets coming from a CDN have a URL generated at compile time. The standard Rails way
24
+ of solving this is to use an _image_tag_, which renders the right URL. However, since Knockout templates are rendered client side, they don't have access to
25
+ this method, unless the templates are generated in the first place using erb or haml.
26
+
27
+ Using [Knockout Assets](https://github.com/hlascelles/knockout-assets) has three advantages over using a standard _image_tag_ in knockout templates.
28
+
29
+ * The knockout templates files need not be processed on the server side at all. This means that testing them (for example with [Jasmine](http://pivotal.github.io/jasmine) becomes possible).
30
+ * The templates may be served up from a CDN using [Knockout.js-External-Template-Engine](https://github.com/ifandelse/Knockout.js-External-Template-Engine).
31
+ * The images are preloaded by default so templates render with the correct layout instantly (but this can be optionally disabled).
32
+
33
+ ## Options
34
+
35
+ Exclude some images using a regex
36
+
37
+ <%= knockout_assets(exclude: /im.*\//) %>
38
+
39
+ Disable preloading images
40
+
41
+ <%= knockout_assets(preload: false) %>
@@ -1,3 +1,3 @@
1
1
  module KnockoutAssets
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1 @@
1
+ require_relative 'knockout/assets'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knockout-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -40,7 +40,9 @@ files:
40
40
  - lib/knockout/assets/engine.rb
41
41
  - lib/knockout/assets/version.rb
42
42
  - lib/knockout/assets.rb
43
+ - lib/knockout-assets.rb
43
44
  - README.md
45
+ - CHANGELOG.md
44
46
  homepage: https://github.com/hlascelles/knockout-assets
45
47
  licenses: []
46
48
  post_install_message: